Exemplo n.º 1
0
    public void CreateEnemy4Trio(Transform spawn, Transform freepos)
    {
        Hashtable tweenPath  = new Hashtable();
        Hashtable tweenPath1 = new Hashtable();
        Hashtable tweenPath2 = new Hashtable();

        GameObject[] scorpionTrio = new GameObject[3];
        scorpionTrio[0] = SimplePool.Spawn(enemy4Prefab, spawn.position, enemy4Prefab.transform.rotation, true) as GameObject;
        scorpionTrio[0].transform.position = spawn.position;
        scorpionTrio[0].transform.parent   = freepos;
        scorpionTrio[0].GetComponent <MeshCollider>().enabled = true;
        GalagaHelper.enemyFourOrigRotation = scorpionTrio[0].transform.rotation;

        scorpionTrio[1] = SimplePool.Spawn(enemy4Prefab, spawn.position, enemy4Prefab.transform.rotation, true) as GameObject;
        scorpionTrio[1].transform.position = spawn.position;
        scorpionTrio[1].transform.parent   = freepos;
        scorpionTrio[1].GetComponent <MeshCollider>().enabled = true;

        scorpionTrio[2] = SimplePool.Spawn(enemy4Prefab, spawn.position, enemy4Prefab.transform.rotation, true) as GameObject;
        scorpionTrio[2].transform.position = spawn.position;
        scorpionTrio[2].transform.parent   = freepos;
        scorpionTrio[2].GetComponent <MeshCollider>().enabled = true;

        PlayerController player = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerController>();

        _waypoints = new List <Vector3>();
        tweenPath.Clear();
        tweenPath1.Clear();
        tweenPath2.Clear();
        if (player)
        {
            for (int i = 0; i < scorpionTrio.Length; i++)
            {
                _waypoints.Clear();
                _waypoints.Add(scorpionTrio[i].transform.position);
                _waypoints.Add(GameObject.FindGameObjectWithTag("Point2").GetComponent <Transform>().position);
                player.GetCirclePathScorpions();
                Vector3[] pathToPlayer = new Vector3[5];
                pathToPlayer = player.scorpionCirclePath;

                for (int x = 0; x < 5; x++)
                {
                    _waypoints.Add(pathToPlayer[x]);
                }
                _waypoints.Add(GameObject.FindGameObjectWithTag("Point2").GetComponent <Transform>().position);
                _waypoints.Add(scorpionTrio[i].transform.position);
                // Copy Vector3 to a new Vector3 array
                //Debug.Log("Waypoints Count: " + _waypoints.Count);
                Vector3[] newVect3 = new Vector3[_waypoints.Count];
                //Debug.Log(_waypoints.Count.ToString().Bold().Italics());
                for (int y = 0; y < _waypoints.Count; y++)
                {
                    newVect3[y] = _waypoints[y];
                }

                if (i == 0)
                {
                    tweenPath.Add("path", newVect3);
                    tweenPath.Add("delay", 0.05f);
                    tweenPath.Add("time", 8.0f);
                    tweenPath.Add("easetype", "linear");
                    tweenPath.Add("orienttopath", true);
                    GalagaHelper.CollectScorpionPaths(scorpionTrio[i], tweenPath);
                }
                else if (i == 1)
                {
                    tweenPath1.Add("path", newVect3);
                    tweenPath1.Add("delay", 0.6f);
                    tweenPath1.Add("time", 8.0f);
                    tweenPath1.Add("easetype", "linear");
                    tweenPath1.Add("orienttopath", true);
                    GalagaHelper.CollectScorpionPaths(scorpionTrio[i], tweenPath1);
                }
                else if (i == 2)
                {
                    tweenPath2.Add("path", newVect3);
                    tweenPath2.Add("delay", 1.0f);
                    tweenPath2.Add("time", 8.0f);
                    tweenPath2.Add("easetype", "linear");
                    tweenPath2.Add("orienttopath", true);
                    tweenPath2.Add("onComplete", "EnemyBack");
                    tweenPath2.Add("onCompleteTarget", gameObject);
                    GalagaHelper.CollectScorpionPaths(scorpionTrio[i], tweenPath2);
                }
            }
        }
    }