Beispiel #1
0
 //Since this class/script is meant to hold data in-between other happenings/levels, we don't want it destroyed.
 //Singleton design.
 private void Awake()
 {
     if (m_PreBattleState == null)
     {
         m_PreBattleState = this;
     }
     DontDestroyOnLoad(this.gameObject);
 }
    // Use this for initialization
    void Start()
    {
        currentSelection = 1;
        numButtons       = 8;

        if (enemy)
        {
            selectColour = enemyColour;//enemy fleet have red colours if selected
        }
        else
        {
            selectColour = fleetColour;                          //friendly fleet have green coulours if selected
        }
        targetSprite1 = target1.GetComponent <SpriteRenderer>(); //gets every ships sprite renderer for the border
        targetSprite2 = target2.GetComponent <SpriteRenderer>();
        targetSprite3 = target3.GetComponent <SpriteRenderer>();
        targetSprite4 = target4.GetComponent <SpriteRenderer>();
        targetSprite5 = target5.GetComponent <SpriteRenderer>();
        targetSprite6 = target6.GetComponent <SpriteRenderer>();
        targetSprite7 = target7.GetComponent <SpriteRenderer>();
        targetSprite8 = target8.GetComponent <SpriteRenderer>();

        targetImage1 = target1.GetComponentInChildren <Image>();//gets every ships Image
        targetImage2 = target2.GetComponentInChildren <Image>();
        targetImage3 = target3.GetComponentInChildren <Image>();
        targetImage4 = target4.GetComponentInChildren <Image>();
        targetImage5 = target5.GetComponentInChildren <Image>();
        targetImage6 = target6.GetComponentInChildren <Image>();
        targetImage7 = target7.GetComponentInChildren <Image>();
        targetImage8 = target8.GetComponentInChildren <Image>();

        preBattleState  = GameObject.Find("PreBattleState").GetComponent <PreBattleState>();
        playerInventory = GameObject.Find("P_Inven").GetComponent <PlayerInventory>();

        detectorScript = detectorObject.GetComponent <detector>();
    }