コード例 #1
0
ファイル: fireWall.cs プロジェクト: amona010/CastleKeep-Game
    private void OnTriggerEnter2D(Collider2D other)
    {
        identityHandler attacker = null;

        obj = other.gameObject;

        if (obj.CompareTag("Attacker_red") || obj.CompareTag("Attacker_blue") || obj.CompareTag("Attacker_orange") || obj.CompareTag("Attacker_gray"))
        {
            attacker = obj.GetComponent <identityHandler>();
            attacker.dieIfAtRisk();
        }
    }
コード例 #2
0
 void Start()
 {
     GM               = GameObject.Find("GM");
     stepCounter      = 0;
     success          = false;
     pathData         = new Stack <string>();
     correctPath      = new Stack <string>();
     attackerIdentity = gameObject.GetComponent <identityHandler>();
     healthCTRL       = GM.GetComponent <GameObjectHolder>().HealthAndCurrency;
     gameHealth       = healthCTRL.GetComponent <healthBar>();
     dataHandler      = GM.GetComponent <sendDataToForm>();
     currentMap       = GM.GetComponent <Graph>();
     setRandomID();
     next = currentMap.getStartingPath(transform.position);
     Debug.Log(next);
 }
コード例 #3
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        obj = other.gameObject;
        identityHandler        attacker = null;
        citizenIdentityHandler citizen  = null;

        if (obj.CompareTag("Attacker_red") || obj.CompareTag("Attacker_blue") || obj.CompareTag("Attacker_orange") || obj.CompareTag("Attacker_gray"))
        {
            attacker = obj.GetComponent <identityHandler>();
        }
        else if (obj.CompareTag("Citizen"))
        {
            citizen = obj.GetComponent <citizenIdentityHandler>();
        }

        if (isGold && attacker != null)
        {
            attacker.exposed();
        }
        else
        {
            if (isRed)
            {
                int accuracy = Random.Range(1, 101);
                if ((obj.CompareTag("Attacker_red") || obj.CompareTag("Attacker_blue") || obj.CompareTag("Attacker_orange")))
                {
                    if (redHealth > (redMax / 2f))
                    {
                        attacker.exposed();
                    }
                    else if (redHealth > (redMax / 4f))
                    {
                        if (accuracy > helper.getRedAccuracyLowHealth())
                        {
                            attacker.testIfAccepted(gameObject.name);
                        }
                        else
                        {
                            attacker.redLocationAccepted(gameObject.name);
                        }
                    }
                    else
                    {
                        if (accuracy > helper.getRedAccuracyCriticalHealth())
                        {
                            attacker.testIfAccepted(gameObject.name);
                        }
                        else
                        {
                            attacker.redLocationAccepted(gameObject.name);
                        }
                    }
                }
                else if (obj.CompareTag("Citizen"))
                {
                    if (redHealth > (redMax / 2f))
                    {
                        citizen.redLocationAccepted(gameObject.name);
                    }
                    else if (redHealth > (redMax / 4f))
                    {
                        if (accuracy > helper.getRedCitizenAccuracyLowHealth())
                        {
                            citizen.redLocationAccepted(gameObject.name);
                        }
                        else
                        {
                            citizen.testIfAccepted(gameObject.name);
                        }
                    }
                    else
                    {
                        if (accuracy > helper.getRedCitizenAccuracyCriticalHealth())
                        {
                            citizen.redLocationAccepted(gameObject.name);
                        }
                        else
                        {
                            citizen.testIfAccepted(gameObject.name);
                        }
                    }
                }
            }

            if (isBlue)
            {
                if (attacker != null)
                {
                    attacker.setMarked(gameObject.name);
                }
                else if (citizen != null)
                {
                    citizen.setMarked(gameObject.name);
                }
            }

            if (isOrange && attacker != null)
            {
                if (obj.CompareTag("Attacker_red") && redCounter < helper.getOrangeAttackerLimit())
                {
                    redCounter++;
                    attacker.exposed();
                }
                else if (obj.CompareTag("Attacker_blue") && blueCounter < helper.getOrangeAttackerLimit())
                {
                    blueCounter++;
                    attacker.exposed();
                }
                else if (obj.CompareTag("Attacker_orange") && orangeCounter < helper.getOrangeAttackerLimit())
                {
                    orangeCounter++;
                    attacker.exposed();
                }
                else if (obj.CompareTag("Attacker_gray") && grayCounter < helper.getOrangeAttackerLimit())
                {
                    grayCounter++;
                    attacker.exposed();
                }
            }

            if (isOrange && citizen != null)
            {
                int accuracy = Random.Range(1, 101);

                if (accuracy > helper.getOrangeCitizenAccuracy())
                {
                    citizen.orangeLocationAccepted(gameObject.name);
                }
                else
                {
                    citizen.testIfOrangeAccepted(gameObject.name);
                }
            }
        }
    }