예제 #1
0
    private void CreateStals()
    {
        Transform stalParent = new GameObject("Stalactites").transform;

        stalParent.position = new Vector3(0f, 0f, Toolbox.Instance.ZLayers["Stalactite"]);
        for (int i = 0; i < NumStals; i++)
        {
            Stalactite newStal = Instantiate(Resources.Load <Stalactite>("Obstacles/Stalactite"), stalParent);
            newStal.transform.position = Toolbox.Instance.HoldingArea;
            newStal.UnstableStalactite = false;
            _stals.Add(newStal);
        }
    }
예제 #2
0
 private void GetScriptComponents()
 {
     Stal           = GetComponentInParent <Stalactite>();
     TelegraphImage = GetComponent <SpriteRenderer>();
     foreach (Transform TF in Stal.GetComponent <Transform>())
     {
         if (TF.name == "StalObject")
         {
             Body = TF;
         }
         else if (TF.name == "StalTrigger")
         {
             Trigger = TF;
         }
     }
 }
예제 #3
0
 private void GetStalComponents()
 {
     StalBody    = null;
     StalTrigger = null;
     StalScript  = Stal.GetComponent <Stalactite>();
     foreach (Transform StalChild in Stal)
     {
         if (StalChild.name == "StalObject")
         {
             StalBody = StalChild;
         }
         else if (StalChild.name == "StalTrigger")
         {
             StalTrigger = StalChild.GetComponent <SpriteRenderer>();
         }
     }
 }
예제 #4
0
    private void StoreStalactites()
    {
        var stalCounts = GetObjCounts(_stalParent);

        for (int i = 0; i < _numSections; i++)
        {
            Level.Caves[i].Stals = new StalPool.StalType[stalCounts[i]];
        }

        int[] stalNum = new int[_numSections];
        foreach (Transform stal in _stalParent)
        {
            Transform stalObj     = null;
            Transform stalTrigger = null;
            foreach (Transform stalChild in stal)
            {
                if (stalChild.name == "StalObject")
                {
                    stalObj = stalChild;
                }
                else if (stalChild.name == "StalTrigger")
                {
                    stalTrigger = stalChild;
                }
            }

            int index = Mathf.RoundToInt(stal.position.x / _tileSizeX);

            StalPool.StalType newStal    = Level.Caves[index].Stals[stalNum[index]];
            Stalactite        stalScript = stal.GetComponent <Stalactite>();
            newStal.SpawnTranform = new Spawnable.SpawnType
            {
                Pos      = new Vector2(stal.position.x - _tileSizeX * index, stal.position.y),
                Scale    = stalObj != null ? stalObj.localScale : Vector3.zero,
                Rotation = stalObj != null ? stalObj.localRotation : Quaternion.identity
            };
            newStal.DropEnabled = stalScript.UnstableStalactite;
            newStal.Flipped     = stalScript.Flipped;
            if (stalTrigger != null)
            {
                newStal.TriggerPos = new Vector2(stalTrigger.position.x - _tileSizeX * index, stalTrigger.position.y);
            }
            Level.Caves[index].Stals[stalNum[index]] = newStal;
            stalNum[index]++;
        }
    }
예제 #5
0
    private void SetStalactites(GameObject stals, StalPool.StalType[] stalList, int posIndex)
    {
        if (stalList == null)
        {
            return;
        }
        foreach (StalPool.StalType stal in stalList)
        {
            GameObject newStal = (GameObject)Instantiate(Resources.Load("Obstacles/EditorStalactite"), stals.transform);
            newStal.name = "Stalactite";
            Transform  stalObj     = null;
            Transform  stalTrigger = null;
            Stalactite stalScript  = newStal.GetComponent <Stalactite>();

            foreach (Transform stalChild in newStal.transform)
            {
                if (stalChild.name == "StalObject")
                {
                    stalObj = stalChild;
                }
                else if (stalChild.name == "StalTrigger")
                {
                    stalTrigger = stalChild;
                }
            }

            newStal.transform.position = new Vector3(stal.SpawnTranform.Pos.x + posIndex * _tileSizeX, stal.SpawnTranform.Pos.y, _stalZ);
            if (stalObj != null)
            {
                stalObj.localScale    = stal.SpawnTranform.Scale;
                stalObj.localRotation = stal.SpawnTranform.Rotation;
            }
            stalScript.Flipped            = stal.Flipped;
            stalScript.UnstableStalactite = stal.DropEnabled;
            if (stalTrigger != null)
            {
                stalTrigger.position = new Vector2(stal.TriggerPos.x + posIndex * _tileSizeX, stal.TriggerPos.y);
            }
        }
    }
예제 #6
0
    private void GetComponentList()
    {
        GameObject thePlayer = GameObject.FindGameObjectWithTag("Player");

        if (thePlayer)
        {
            _playerBody    = GameObject.FindGameObjectWithTag("Player").transform;
            _playerControl = _playerBody.GetComponent <PlayerController>();
        }

        TriggerSprite = GetComponent <SpriteRenderer>();
        _stal         = GetComponentInParent <Stalactite>();
        _anim         = _stal.GetComponentInChildren <StalAnimationHandler>();

        foreach (Transform tf in _stal.GetComponent <Transform>())
        {
            if (tf.name == "StalObject")
            {
                _stalBody = tf.GetComponent <Rigidbody2D>();
            }
        }
    }
예제 #7
0
 void Awake()
 {
     _anim = GetComponent <Animator>();
     _stal = GetComponentInParent <Stalactite>();
     NewStalactite();
 }