예제 #1
0
 public void Cast(GameObject target, bool facingRight, float mod)
 {
     cooldownTimer    = Cooldown;
     inst             = UnityEngine.Object.Instantiate(Prefab).GetComponent <Castable>();
     inst.movingRight = facingRight;
     inst.AssignModifier(mod);
     inst.Cast(target);
 }
예제 #2
0
        protected void formatSpawn(Castable spawn)
        {
            spawn.AssignModifier(damageModifier);
            //Move bolt to top of volcano
            spawn.transform.position = transform.position + new Vector3(0, 1.5f);

            //Calculate a random direction to shoot the bolt.
            float angle = -Mathf.Deg2Rad * UnityEngine.Random.Range(0, 180);
            //The y-coordinate in the rotation formula is not necesarry as we're rotating from <-1, 0> (Vector2.left)
            float x = -1 * Mathf.Cos(angle);
            float y = -1 * Mathf.Sin(angle);

            spawn.GetComponent <Rigidbody2D> ().velocity = new Vector2(x * Speed, y * Speed);
        }