Beispiel #1
0
    public override void EndTouch(SceneControl.TouchEvent args)
    {
        // Now, what have we targeted from this click (if anything)
        Ray        r = Camera.main.ScreenPointToRay(args.currentPosition);
        RaycastHit r_hit;

        // DID we point to anything from the touch?
        if (Physics.Raycast(r, out r_hit, Mathf.Infinity))
        {
            GameObject go = Instantiate(lightningPrefab, r_hit.point, Quaternion.Euler(-90.0f, 0.0f, 0.0f)) as GameObject;

            Collider[] objs = Physics.OverlapSphere(r_hit.point, lightningRange);
            foreach (Collider obj in objs)
            {
                commonAI gameObj = obj.GetComponent <commonAI>();
                if (gameObj != null)
                {
                    ICanBeStruckDown strike = gameObj as ICanBeStruckDown;
                    if (strike != null)
                    {
                        //Debug.Log ("Found object: " + obj.name);
                        strike.StrikeDown();
                    }
                }
                Rigidbody rb = obj.GetComponent <Rigidbody>();
                if (rb != null)
                {
                    rb.AddForce(5.0f * (rb.transform.position - r_hit.point).normalized, ForceMode.Impulse);
                }
            }

            Destroy(go, go.GetComponent <ParticleSystem>().duration);
        }
    }
Beispiel #2
0
 public override void EndTouch(SceneControl.TouchEvent args)
 {
     if (cancelled || !firstMovementComplete)
     {
         return;
     }
     // End of the touch. Perform the influence now.
     Collider[] objs = Physics.OverlapSphere(firstTouchPosition, 12.0f);
     foreach (Collider obj in objs)
     {
         commonAI gameObj = obj.GetComponent <commonAI>();
         if (gameObj != null && gameObj.enabled)
         {
             ICanBeInfluenced inf = gameObj as ICanBeInfluenced;
             if (inf != null)
             {
                 //Debug.Log ("Found object: " + obj.name);
                 inf.BeInfluenced(firstDirection);
                 continue;
             }
         }
         StateMachineDriver statemachine = obj.GetComponent <StateMachineDriver>();
         if (statemachine != null && statemachine.enabled)
         {
             statemachine.AddAction("influence", firstDirection);
             continue;
         }
     }
 }
Beispiel #3
0
    public override void MoveTouch(SceneControl.TouchEvent args)
    {
        if (cancelled)
        {
            return;
        }

        Ray        r = Camera.main.ScreenPointToRay(args.currentPosition);
        RaycastHit r_hit;

        // DID we point to anything from the touch?
        if (Physics.Raycast(r, out r_hit, Mathf.Infinity))
        {
            Vector3 groundPoint = new Vector3(r_hit.point.x, lastTouchPosition.y, r_hit.point.z);
            if (!firstMovementComplete)
            {
                Vector3 direction = (groundPoint - lastTouchPosition);
                if (direction.magnitude > 7.0f)
                {
                    firstDirection        = (groundPoint - lastTouchPosition).normalized;
                    firstMovementComplete = true;
                }
            }
            if ((groundPoint - lastTouchPosition).magnitude > 7.0f)
            {
                // Instantiate a magical light "spell"
                GameObject go = Instantiate(magicalLightPrefab, lastTouchPosition, Quaternion.Euler(-90.0f, 0.0f, 0.0f)) as GameObject;
                Destroy(go, go.GetComponent <ParticleSystem>().duration);

                lastTouchPosition = groundPoint;
            }
        }
    }
Beispiel #4
0
    public override void StartTouch(SceneControl.TouchEvent args)
    {
        cancelled             = false;
        firstMovementComplete = false;

        // Now, what have we targeted from this click (if anything)
        Ray        r = Camera.main.ScreenPointToRay(args.currentPosition);
        RaycastHit r_hit;

        // DID we point to anything from the touch?
        if (Physics.Raycast(r, out r_hit, Mathf.Infinity))
        {
            // Only concerned with terrains for the touch down
            if (r_hit.collider is TerrainCollider || r_hit.collider.name == "Playable Area")
            {
                firstTouchPosition = r_hit.point;
                lastTouchPosition  = r_hit.point;
            }
            else
            {
                //Debug.Log ("Cancelling click");
                cancelled = true;
            }
        }
    }
Beispiel #5
0
    public override void StartTouch(SceneControl.TouchEvent args)
    {
        // Now, what have we targeted from this click (if anything)
        Ray        r = Camera.main.ScreenPointToRay(args.currentPosition);
        RaycastHit r_hit;

        // DID we point to anything from the touch?
        if (Physics.Raycast(r, out r_hit, Mathf.Infinity))
        {
            GameObject zai = globalEvents.manaControllerService.RequestBuyZombie(r_hit.point, new Quaternion());
            if (zai != null)
            {
                zombieAI ai = zai.GetComponent <zombieAI>();
                if (ai != null)
                {
                    ai.Start();
                }

                if (zombieAppearanceEffect != null)
                {
                    GameObject go = Instantiate(zombieAppearanceEffect, r_hit.point, Quaternion.Euler(-90.0f, 0.0f, 0.0f)) as GameObject;
                    Destroy(go, go.GetComponent <ParticleSystem>().duration);
                }
            }
        }
    }
Beispiel #6
0
 virtual public void CancelTouch(SceneControl.TouchEvent args)
 {
 }
Beispiel #7
0
 virtual public void EndTouch(SceneControl.TouchEvent args)
 {
 }