Beispiel #1
0
    public void Struck(PG_Shot shot)
    {
        latest = shot;

        Texture upgrade = renderer.material.GetTexture("_DecalTex");

        if (upgrade != null)
        {
            shot.gun.networkView.RPC("Upgrade", RPCMode.AllBuffered, upgrade.name);
            networkView.RPC("SetDecal", RPCMode.AllBuffered, "");
            Network.Instantiate(upgradeClaim, transform.position, Quaternion.identity, 210);
        }

        if (building.owned) { return; } // nothing to be done <-- COMMENT TO UNDO BUILDING LOCKING

        foreach (Transform child in transform.parent) // foreach cube in building, do splash effect
        {
            float distance = Vector3.Distance(transform.position, child.position);

            if (distance < adjacentCubeDistance) // only consider adjacent cubes
            {
                PG_Cube cubeScript = child.GetComponent<PG_Cube>();

                if (cubeScript != null) // this is a cube
                {
                    cubeScript.Effects(shot, distance);
                }
            }
        }
    }
Beispiel #2
0
    public void Effects(PG_Shot shot, float distance)
    {
        if(shot!=null && shot.gun != null && distance!=null){
            float effect = shot.gun.power - distance;

            Texture texture = shot.renderer.sharedMaterial.mainTexture;
            if (texture == blue)
            {
                amountRed = Mathf.Max(0, amountRed - effect);
                amountBlue = Mathf.Min(maxColor, amountBlue + effect);

                if (amountBlue > resistence)
                {
                    if (Network.isClient || Network.isServer)
                    {
                        networkView.RPC("UpdateCubeMaterial", RPCMode.AllBuffered, "blue",shot.getShotOwnerID());
                    }
                    else // remove when all shall be networked (in the final game)
                    {
                        //renderer.material = blue;
                        renderer.material.SetTexture("_MainTex", blue);
                    }
                }
            }
            else if (texture == red)
            {
                amountBlue = Mathf.Max(0, amountBlue - effect);
                amountRed = Mathf.Min(maxColor, amountRed + effect);

                if (amountRed > resistence)
                {
                    if (Network.isClient || Network.isServer)
                    {
                        networkView.RPC("UpdateCubeMaterial", RPCMode.AllBuffered, "red",shot.getShotOwnerID());
                    }
                    else // remove when all shall be networked (in the final game)
                    {
                        //renderer.material = red;
                        renderer.material.SetTexture("_MainTex", red);
                    }
                }
            }
        }
    }
Beispiel #3
0
    public void SetColor(PG_Shot shot)
    {
        if (amountBlue > resistence && renderer.material.color != gameData.blue)
        {
            networkView.RPC("SetBlue", RPCMode.AllBuffered);

            if (shot != null && shot.gun != null && shot.gun.tag != "Bot")
            {
                networkView.RPC("InformCaptor", RPCMode.AllBuffered, shot.gun.transform.parent.networkView.viewID);
            }
        }
        else if (amountRed > resistence && renderer.material.color != gameData.red)
        {
            networkView.RPC("SetRed", RPCMode.AllBuffered);

            if (shot != null && shot.gun != null && shot.gun.tag != "Bot")
            {
                networkView.RPC("InformCaptor", RPCMode.AllBuffered, shot.gun.transform.parent.networkView.viewID);
            }
        }
    }
Beispiel #4
0
    private void Effects(PG_Shot shot, float distance)
    {
        if (shot != null && shot.gun != null)
        {
            float effect = shot.gun.power - distance;

            Texture texture = shot.renderer.sharedMaterial.mainTexture;
            if (texture == blue)
            {
                amountRed = Mathf.Max(0, amountRed - effect);
                amountBlue = Mathf.Min(maxColor, amountBlue + effect);
            }
            else if (texture == red)
            {
                amountBlue = Mathf.Max(0, amountBlue - effect);
                amountRed = Mathf.Min(maxColor, amountRed + effect);
            }
            SetColor(shot);
        }
    }
Beispiel #5
0
    public void Struck(PG_Shot shot)
    {
        if(shot!=null){
            foreach (Transform child in transform.parent) // splash effect
            {
                float distance = Vector3.Distance(transform.position, child.position);
                //testing for minimum reaction on adjacent
                if (distance < 2.9f) // only consider adjacent cubes
                {
                    PG_Cube cubeScript = child.GetComponent<PG_Cube>();
                    if (cubeScript != null) // this is a cube
                    {	if(shot!=null){
                            cubeScript.Effects(shot, distance);
                        }
                    }
                }
            }

            Texture upgrade = renderer.material.GetTexture("_DecalTex");
            if (upgrade != null)
            {
                // this is silly, fix with an enum in production
                if (upgrade.name == "BlastShots")
                {
                    if (shot.gun.bs == null) {
                        shot.gun.bs = upgrade;
                        shot.gun.power += 2;
                    }
                }
                else if (upgrade.name == "EvadeBots")
                {
                    if (shot.gun.eb == null) {
                        shot.gun.eb = upgrade;
                        // do nothing else, for now
                    }
                }
                else if (upgrade.name == "FastShots")
                {
                    if (shot.gun.fs == null) {
                        shot.gun.fs = upgrade;
                        shot.gun.speed *= 2;
                    }
                }
                else if (upgrade.name == "MoveQuick")
                {
                    if (shot.gun.qm == null) {
                        shot.gun.qm = upgrade;
                        CharacterMotor cm = shot.gun.transform.parent.GetComponent<CharacterMotor>();
                        cm.jumping.baseHeight = 4;
                        cm.movement.maxForwardSpeed *= 2;
                        cm.movement.maxSidewaysSpeed *= 2;
                        cm.movement.maxBackwardsSpeed *= 2;
                        cm.movement.maxGroundAcceleration *= 3;
                    }
                }
                else if (upgrade.name == "RapidFire")
                {
                    if (shot.gun.rf == null) {
                        shot.gun.rf = upgrade;
                        shot.gun.rate /= 2;
                    }
                }
                renderer.material.SetTexture("_DecalTex", null);
            }
        }
    }