//////////***//////////


    void Awake()
    {
        battleController = GameObject.Find("Battle Controller").GetComponent <BattleControllerScript> ();

        //Adds ship to the master list of ships in the battle.
        if (teamColor == "Green")
        {
            battleController.greenAI.Add(this.gameObject);
        }
        else if (teamColor == "Purple")
        {
            battleController.purpleAI.Add(this.gameObject);
        }
        else if (teamColor == "Blue")
        {
            battleController.blueAI.Add(this.gameObject);
        }

        //Used to make the ships appear under the UI
        layerMask    = 1 << layer;
        invLayerMask = ~(layerMask);

        mainCam      = GameObject.FindWithTag("MainCamera").GetComponent <CameraController> ();
        firstTurnMin = battleController.minFirstTurn;
        firstTurnMax = battleController.maxFirstTurn;
    }
    public BattleControllerScript BattleController()
    {
        if (null == battleControllerScript)
        {
            battleControllerScript = GameObject.Find("BattleController").GetComponent <BattleControllerScript>();
        }

        return(battleControllerScript);
    }
Beispiel #3
0
    public void calculateDamageAndScore(int damage, int power)
    {
        // Calculate damage and score
        BattleControllerScript script = target.GetComponent <BattleControllerScript>();
        int score  = script.score;
        int health = script.health;

        target.GetPhotonView().RPC("DecreaseHealth", RpcTarget.All, damage, power);
        if (health <= damage)
        {
            int gameMode = (int)PhotonNetwork.CurrentRoom.CustomProperties["mode"];
            if (gameMode == 2)
            {
                this.gameObject.GetPhotonView().RPC("IncreaseScore", RpcTarget.All, score / 2 + 1);
            }
            else
            {
                GameObject.Find("BattleManager").GetComponent <BattleManager>().ProcessVictory(this.gameObject);
            }
        }
    }
Beispiel #4
0
    public void SetTarget(BattleControllerScript _target)
    {
        // Cache references for efficiency because we are going to reuse them.

        this.target = _target;

        targetTransform = this.target.GetComponent <Transform>();
        targetRenderer  = this.target.GetComponentInChildren <Renderer>();


        CharacterController _characterController = this.target.GetComponent <CharacterController>();

        // Get data from the Player that won't change during the lifetime of this Component
        if (_characterController != null)
        {
            characterControllerHeight = _characterController.height;
        }

        if (playerNameText != null)
        {
            playerNameText.text = this.target.photonView.Owner.NickName;
        }
    }
    public BattleControllerScript BattleController()
    {
        if(null == battleControllerScript)
            battleControllerScript = GameObject.Find("BattleController").GetComponent<BattleControllerScript>();

        return battleControllerScript;
    }