Advertisement
Guest User

Ranged.cs

a guest
Sep 21st, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.29 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class Ranged : Skillverhalten {
  6.     private const string name = "Ranged";
  7.     private const string Tooltip = "Eine Range Attack!";
  8.     private const VerhaltenStartZeit startTime = VerhaltenStartZeit.Beginning;
  9.  
  10.     private float minDistance;
  11.     private float maxDistance;
  12.     private bool isRandomm;
  13.     private float lifedistance;
  14.  
  15.     public Ranged(float minDist, float maxDist, bool isRandom)
  16.         : base(new BasicObjectInfos(name, Tooltip), startTime){
  17.  
  18.  
  19.         minDistance = minDist;
  20.         maxDistance = maxDist;
  21.         isRandomm = isRandom;
  22.    
  23.     }
  24.  
  25.  
  26.     public override void PerformVerhalten(Vector3 startPosition)
  27.     {
  28.         lifedistance = isRandomm ? Random.Range(minDistance, maxDistance) : maxDistance;
  29.         StartCoroutine (CheckDistance (startPosition));
  30.  
  31.     }
  32.  
  33.     private IEnumerable CheckDistance(Vector3 startPosition){
  34.         float tempdistance = Vector3.Distance (startPosition, this.transform.position);
  35.         while (tempdistance > lifedistance) {
  36.            
  37.             tempdistance = Vector3.Distance (startPosition, this.transform.position);
  38.  
  39.         }
  40.         this.gameObject.SetActive (false);
  41.         yield return null;
  42.  
  43.     }
  44.  
  45.     public float MinDistance{
  46.         get {return minDistance;  }
  47.     }
  48.  
  49.     public float MaxDistance{
  50.         get {return maxDistance;  }
  51.     }
  52.  
  53.  
  54.  
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement