Esempio n. 1
0
        public void DoRun(SimpleAI sAI, string code)
        {
            if (code == "Die")
            {
                sAI.Destroy();
            }

            TreeObject to = (TreeObject)sAI.mCharacter;

            if (to.timer < 1.0f)
            {
                to.timer += Time.deltaTime;
                return;
            }
            SimpleAI[] SimpleAIs = SimpleAISetSingleton.getInstance().GetComponent <SimpleAISet> ().FindAIsWithRiaus(sAI.mAIRT.transform.position, 5.0f, 1 << LayerMask.NameToLayer("Default"), "Glass");
            to.timer      = 0.0f;
            to.mTempLife -= 180 + (int)(30 * to.mStrongRate);
            for (int i = 0; i < SimpleAIs.Length; i++)
            {
                glassObject go = (glassObject)SimpleAIs [i].mCharacter;
                if (go.mHp > 500)
                {
                    to.mTempLife += (int)(go.mHp / 500.0f);
                    //Debug.Log ("Grass");
                }
            }
        }
Esempio n. 2
0
        public void DoRun(SimpleAI sAI, string code)
        {
            if (code == "Die")
            {
                sAI.Destroy();
            }
            glassObject go = (glassObject)sAI.mCharacter;

            if (go.timer < 1.0f)
            {
                go.timer += Time.deltaTime;
                return;
            }
            SimpleAI[] SimpleAIs = SimpleAISetSingleton.getInstance().GetComponent <SimpleAISet> ().FindAIsWithRiaus(sAI.mAIRT.transform.position, 5.0f, 1 << LayerMask.NameToLayer("Default"), "Tree");
            go.timer = 0.0f;

            go.mHp -= 50;
            for (int i = 0; i < SimpleAIs.Length; i++)
            {
                TreeObject to = (TreeObject)SimpleAIs [i].mCharacter;
                if (to.mTempLife > 1500)
                {
                    go.mHp += (int)(to.mTempLife / 50.0f);
                }
            }
        }
Esempio n. 3
0
        public void DoRun(SimpleAI sAI, string code)
        {
            string s = code;

            ((CowObject)sAI.mCharacter).timer += Time.deltaTime;
            if (((int)((CowObject)sAI.mCharacter).timer) - ((CowObject)sAI.mCharacter).lastTime > 0)
            {
                ((CowObject)sAI.mCharacter).mTempLife -= 30 + (int)(10 * ((CowObject)sAI.mCharacter).mStrongRate);
                ((CowObject)sAI.mCharacter).lastTime   = ((int)((CowObject)sAI.mCharacter).timer);
            }
            if (code == "Die")
            {
                sAI.Destroy();
            }
            else if (code == "Round")
            {
                ((CowObject)sAI.mCharacter).mGlassTarget = null;
                if (((CowObject)sAI.mCharacter).RoundTimer > 0.0f && (((CowObject)sAI.mCharacter)).RoundTarget != Vector3.zero)
                {
                    float distance = Vector3.Distance(sAI.mAIRT.transform.position, ((CowObject)sAI.mCharacter).RoundTarget);
                    if (distance > 1.5f)
                    {
                        sAI.GetComponent <AIMove> ().mDirection   = ((CowObject)sAI.mCharacter).RoundTarget - sAI.mAIRT.transform.position;
                        sAI.GetComponent <AIMove> ().mDirection.y = 0.0f;
                        sAI.GetComponent <AIMove> ().mVelocity    = ((CowObject)sAI.mCharacter).mVelocity;
                    }
                    else
                    {
                        sAI.GetComponent <AIMove> ().mVelocity = 0.0f;
                    }
                    ((CowObject)sAI.mCharacter).RoundTimer -= Time.deltaTime;
                }
                else
                {
                    ((CowObject)sAI.mCharacter).RoundTimer  = 4.5f;
                    ((CowObject)sAI.mCharacter).RoundTarget = sAI.GeneratePos + new Vector3(Random.Range(-10, 10), 0, Random.Range(-10, 10));
                }
            }
            else
            {
                ((CowObject)sAI.mCharacter).RoundTarget = Vector3.zero;
                ((CowObject)sAI.mCharacter).RoundTimer  = 0.0f;
                if (((CowObject)sAI.mCharacter).mGlassTarget == null || ((CowObject)sAI.mCharacter).mGlassTarget.mAIRT == null)
                {
                    SimpleAI[] SimpleAIs  = SimpleAISetSingleton.getInstance().GetComponent <SimpleAISet> ().FindAIsWithRiaus(sAI.mAIRT.transform.position, 9.5f, 1 << LayerMask.NameToLayer("Default"), "Glass");
                    int        startIndex = Random.Range(0, SimpleAIs.Length);
                    bool       Type       = ((CowObject)sAI.mCharacter).Type;
                    for (int i = startIndex; i < SimpleAIs.Length; i++)
                    {
                        float f2 = ComputeGreen(SimpleAIs[i]);
                        if (f2 > 0.5f && f2 < 0.75f)
                        {
                            f2 += 0.25f;
                        }
                        else if (f2 < 0.5f && f2 > 0.25f)
                        {
                            f2 -= 0.25f;
                        }

                        if (Type)
                        {
                            f2 = f2;
                            if (f2 < 0.15f)
                            {
                                f2 -= 0.11f;
                            }
                        }
                        else
                        {
                            f2 = 1.0f - f2;
                            if (f2 < 0.15f)
                            {
                                f2 -= 0.11f;
                            }
                        }

                        if (Random.Range(0.0f, 1.0f) < f2)
                        {
                            ((CowObject)sAI.mCharacter).mGlassTarget = SimpleAIs [i];
                            //Debug.Log (SimpleAIs[i].mAIRT.GetComponent<MeshRenderer>().material.color+"  "+Type.ToString());
                            break;
                        }
                    }
                    s += "Finding";
                }
                else
                {
                    float distance = Vector3.Distance(sAI.mAIRT.transform.position, ((CowObject)sAI.mCharacter).mGlassTarget.mAIRT.transform.position);
                    if (distance > 1.5f)
                    {
                        sAI.GetComponent <AIMove> ().mDirection   = ((CowObject)sAI.mCharacter).mGlassTarget.mAIRT.transform.position - sAI.mAIRT.transform.position;
                        sAI.GetComponent <AIMove> ().mDirection.y = 0.0f;
                        sAI.GetComponent <AIMove> ().mVelocity    = ((CowObject)sAI.mCharacter).mVelocity;
                    }
                    else
                    {
                        sAI.GetComponent <AIMove> ().mVelocity = 0.0f;
                        if (((CowObject)sAI.mCharacter).EatTimer < 1.0f)
                        {
                            ((CowObject)sAI.mCharacter).EatTimer += Time.deltaTime;
                        }
                        else
                        {
                            ((CowObject)sAI.mCharacter).mTempLife += 40;
                            ((CowObject)sAI.mCharacter).mTempLife  = Mathf.Min(((CowObject)sAI.mCharacter).mTempLife, ((CowObject)sAI.mCharacter).mLife);
                            ((glassObject)((CowObject)sAI.mCharacter).mGlassTarget.mCharacter).mHp -= 120;
                        }
                    }
                }
            }
        }