Beispiel #1
0
    void CmdExplodeOnTarget(uint netId)
    {
        GameObject[] allShips  = GameObject.FindGameObjectsWithTag("PlayerShip");
        bool         shipFound = false;

        for (int i = 0; i < allShips.Length && !shipFound; i++)
        {
            ShipCombat combatRef = allShips[i].GetComponent <ShipCombat>();
            if (combatRef.netId.Value == netId)
            {
                combatRef.hurtMe(damage);
            }
        }
    }
    void CmdBroadcastDataAllShips()
    {
        GameObject[] allShips = GameObject.FindGameObjectsWithTag("PlayerShip");

        //  loop through all ship objects, send data
        for (int i = 0; i < allShips.Length; i++)
        {
            //  broadcast shipHP for this ship
            ShipCombat shipCombatScriptRef = allShips[i].GetComponent <ShipCombat>();
            shipCombatScriptRef.CmdSetHealth(shipCombatScriptRef.currentHP);

            // add more 'paragraphs' for each data value you want to propogate
        }
    }