Esempio n. 1
0
 private void Start()
 {
     this.bird = base.transform.parent.GetComponent <lb_Bird>();
     this.structureCoolDown = false;
     this.treeCoolDown      = false;
     this.init        = true;
     this.collideMask = 0;
 }
Esempio n. 2
0
 private void Start()
 {
     this.bird = base.transform.parent.GetComponent<lb_Bird>();
     this.structureCoolDown = false;
     this.treeCoolDown = false;
     this.init = true;
     this.collideMask = 0;
 }
Esempio n. 3
0
    public Transform metgoragdoll(Vector3 varpvelocity = default(Vector3))
    {
        Transform transform = UnityEngine.Object.Instantiate(this.vargamragdoll, base.transform.position, base.transform.rotation) as Transform;

        transform.localScale = base.transform.localScale;
        this.metcopytransforms(base.transform, transform, varpvelocity * 1f);
        if (this.doCreepySkin)
        {
            transform.gameObject.SendMessage("setSkin", this.health.MySkin.sharedMaterial, SendMessageOptions.DontRequireReceiver);
            this.health.MySkin.GetPropertyBlock(this.bloodPropertyBlock);
            transform.gameObject.SendMessage("setSkinDamageProperty", this.bloodPropertyBlock, SendMessageOptions.DontRequireReceiver);
            if (BoltNetwork.isServer)
            {
                IMutantState         state = base.transform.parent.GetComponent <BoltEntity>().GetState <IMutantState>();
                CoopMutantDummyToken coopMutantDummyToken = new CoopMutantDummyToken();
                coopMutantDummyToken.Scale       = base.transform.localScale;
                coopMutantDummyToken.skinDamage1 = this.bloodPropertyBlock.GetFloat("_Damage1");
                coopMutantDummyToken.skinDamage2 = this.bloodPropertyBlock.GetFloat("_Damage2");
                coopMutantDummyToken.skinDamage3 = this.bloodPropertyBlock.GetFloat("_Damage3");
                coopMutantDummyToken.skinDamage4 = this.bloodPropertyBlock.GetFloat("_Damage4");
                mutantTypeSetup component = base.transform.parent.GetComponent <mutantTypeSetup>();
                if (component)
                {
                    coopMutantDummyToken.storedRagDollName = component.storedRagDollName;
                }
                BoltNetwork.Attach(transform.gameObject, coopMutantDummyToken);
            }
        }
        if (this.animal)
        {
            animalSpawnFunctions component2 = base.transform.root.GetComponent <animalSpawnFunctions>();
            if (component2)
            {
                transform.gameObject.SendMessage("setSkin", component2.meshRenderer.sharedMaterial, SendMessageOptions.DontRequireReceiver);
            }
        }
        if (this.bird)
        {
            lb_Bird component3 = base.transform.GetComponent <lb_Bird>();
            transform.gameObject.SendMessage("setSkin", component3.skin.sharedMaterial, SendMessageOptions.DontRequireReceiver);
        }
        if (this.fish)
        {
            transform.gameObject.SendMessage("doSkinSetup", this.fishScript.fishTypeInt, SendMessageOptions.DontRequireReceiver);
        }
        if (this.burning)
        {
            transform.gameObject.SendMessage("enableFire", SendMessageOptions.DontRequireReceiver);
        }
        if (this.alreadyBurnt)
        {
            transform.gameObject.SendMessage("enableBurntSkin", SendMessageOptions.DontRequireReceiver);
        }
        this.burning      = false;
        this.alreadyBurnt = false;
        return(transform);
    }
    void MoveBirdToPoint(lb_Bird bird, Vector3 position)
    {
        var distance = Vector3.Distance(bird.transform.position, position);

        if (!bird.flying && !bird.landing && distance > .4f)
        {
            Debug.LogFormat("Starting to fly to {0}", position);
            bird.SendMessage("FlyToTarget", position);
        }
        else if (!bird.flying && !bird.landing)
        {
            bird.transform.position = Vector3.Lerp(bird.transform.position, position, Time.deltaTime * 10f);
            var rotation = Quaternion.LookRotation(m_Cam.transform.position - bird.transform.position);
            bird.transform.rotation = Quaternion.Slerp(bird.transform.rotation, rotation, Time.deltaTime * 10f);
        }
    }
Esempio n. 5
0
 private void checkHandConditions()
 {
     if (LocalPlayer.GameObject && this.currentCamera)
     {
         this.birdCount = 0;
         if (LocalPlayer.Ridigbody.velocity.magnitude < 0.2f && !this.breakBool && LocalPlayer.TargetFunctions.allAttackers == 0 && !LocalPlayer.Animator.GetBool("bookHeld"))
         {
             for (int i = 0; i < this.myBirds.Length; i++)
             {
                 if (this.myBirds[i])
                 {
                     lb_Bird component = this.myBirds[i].GetComponent <lb_Bird>();
                     if (component && component.birdVisible)
                     {
                         this.birdCount++;
                     }
                 }
             }
             if (this.birdCount > 4)
             {
                 this.repeatCount++;
             }
             if (this.repeatCount > 3 && UnityEngine.Random.value < 0.5f)
             {
                 LocalPlayer.GameObject.SendMessage("doBirdOnHand");
                 this.repeatCount = 0;
                 this.breakBool   = true;
                 base.Invoke("resetBreakBool", 100f);
             }
         }
         else
         {
             this.repeatCount = 0;
             this.birdCount   = 0;
         }
     }
 }
Esempio n. 6
0
        public static void KillAll()
        {
            animalHealth[] array  = FindObjectsOfType <animalHealth>();
            animalHealth[] array2 = array;
            for (int i = 0; i < array2.Length; i++)
            {
                animalHealth animalHealth = array2[i];
                if (animalHealth.gameObject.activeInHierarchy)
                {
                    animalHealth.SendMessage("Die");
                }
            }

            lb_Bird[] arrayB  = FindObjectsOfType <lb_Bird>();
            lb_Bird[] arrayB2 = arrayB;
            for (int i = 0; i < arrayB2.Length; i++)
            {
                lb_Bird birdHealth = arrayB2[i];
                if (birdHealth.gameObject.activeInHierarchy)
                {
                    birdHealth.SendMessage("die");
                }
            }
        }
Esempio n. 7
0
    public Transform metgoragdoll(Vector3 varpvelocity = default(Vector3))
    {
        Transform transform = UnityEngine.Object.Instantiate <Transform>(this.vargamragdoll, base.transform.position, base.transform.rotation);

        if (!this.ignoreScale)
        {
            transform.localScale = base.transform.localScale;
        }
        this.metcopytransforms(base.transform, transform, varpvelocity * 1f);
        if (this.doCreepySkin && this.enemyHealth)
        {
            transform.gameObject.SendMessage("setSkin", this.enemyHealth.MySkin.sharedMaterial, SendMessageOptions.DontRequireReceiver);
            this.enemyHealth.MySkin.GetPropertyBlock(this.bloodPropertyBlock);
            transform.gameObject.SendMessage("setSkinDamageProperty", this.bloodPropertyBlock, SendMessageOptions.DontRequireReceiver);
            if (this.enemyHealth.Fire.Length > 0)
            {
                mutantTransferFire component = base.transform.parent.GetComponent <mutantTransferFire>();
                foreach (GameObject gameObject in this.enemyHealth.Fire)
                {
                    if (gameObject.activeSelf && component)
                    {
                        component.transferFireToTarget(gameObject, transform.gameObject);
                    }
                }
            }
            if (BoltNetwork.isServer)
            {
                BoltEntity component2 = base.transform.parent.GetComponent <BoltEntity>();
                if (component2)
                {
                    IMutantState         state = component2.GetState <IMutantState>();
                    CoopMutantDummyToken coopMutantDummyToken = new CoopMutantDummyToken();
                    coopMutantDummyToken.Scale       = base.transform.localScale;
                    coopMutantDummyToken.skinDamage1 = this.bloodPropertyBlock.GetFloat("_Damage1");
                    coopMutantDummyToken.skinDamage2 = this.bloodPropertyBlock.GetFloat("_Damage2");
                    coopMutantDummyToken.skinDamage3 = this.bloodPropertyBlock.GetFloat("_Damage3");
                    coopMutantDummyToken.skinDamage4 = this.bloodPropertyBlock.GetFloat("_Damage4");
                    coopMutantDummyToken.skinColor   = this.enemyHealth.MySkin.sharedMaterial.GetColor("_Color");
                    mutantTypeSetup component3 = base.transform.parent.GetComponent <mutantTypeSetup>();
                    if (component3)
                    {
                    }
                    BoltNetwork.Attach(transform.gameObject, coopMutantDummyToken);
                }
            }
        }
        if (this.animalHealth && this.animalHealth.mySkin)
        {
            this.animalHealth.mySkin.GetPropertyBlock(this.bloodPropertyBlock);
            float @float = this.bloodPropertyBlock.GetFloat("_Damage1");
            transform.gameObject.SendMessage("setSkinDamageProperty", this.bloodPropertyBlock, SendMessageOptions.DontRequireReceiver);
        }
        if (this.animalHealth && this.animalHealth.Fire)
        {
            mutantTransferFire component4;
            if (base.transform.parent)
            {
                component4 = base.transform.parent.GetComponent <mutantTransferFire>();
            }
            else
            {
                component4 = base.transform.GetComponent <mutantTransferFire>();
            }
            if (this.animalHealth.Fire.activeSelf && component4)
            {
                component4.transferFireToTarget(this.animalHealth.Fire, transform.gameObject);
            }
        }
        if (this.bat && this.burning)
        {
            transform.gameObject.SendMessage("enableFire", SendMessageOptions.DontRequireReceiver);
        }
        if (this.animal)
        {
            animalSpawnFunctions component5 = base.transform.root.GetComponent <animalSpawnFunctions>();
            if (component5)
            {
                transform.gameObject.SendMessage("setSkin", component5.meshRenderer.sharedMaterial, SendMessageOptions.DontRequireReceiver);
            }
            if (this.ca && this.ca.isSnow)
            {
                transform.gameObject.SendMessage("setupSnowRabbitTypeTrigger", SendMessageOptions.DontRequireReceiver);
            }
        }
        if (this.bird)
        {
            if (this.burning)
            {
                transform.gameObject.SendMessage("enableFire", SendMessageOptions.DontRequireReceiver);
            }
            lb_Bird component6 = base.transform.GetComponent <lb_Bird>();
            transform.gameObject.SendMessage("setSkin", component6.skin.sharedMaterial, SendMessageOptions.DontRequireReceiver);
        }
        if (this.fish)
        {
            transform.gameObject.SendMessage("doSkinSetup", this.fishScript.fishTypeInt, SendMessageOptions.DontRequireReceiver);
            transform.gameObject.SendMessage("setupFishType", this.fishScript.fishNatureGuideValue, SendMessageOptions.DontRequireReceiver);
        }
        if (this.alreadyBurnt)
        {
            transform.gameObject.SendMessage("enableBurntSkin", SendMessageOptions.DontRequireReceiver);
        }
        if (this.ast)
        {
            arrowStickToTarget component7 = transform.GetComponent <arrowStickToTarget>();
            if (component7)
            {
                int num = 0;
                foreach (KeyValuePair <Transform, int> keyValuePair in this.ast.stuckArrows)
                {
                    if (keyValuePair.Key)
                    {
                        component7.CreatureType(this.ast.IsAnimal, this.ast.IsBird, this.ast.IsFish);
                        int arrowType = 0;
                        if (num < this.ast.stuckArrowsTypeList.Count)
                        {
                            arrowType = this.ast.stuckArrowsTypeList[num];
                        }
                        component7.applyStuckArrowToDummy(keyValuePair.Key, keyValuePair.Key.localPosition, keyValuePair.Key.localRotation, keyValuePair.Value, arrowType);
                        num++;
                    }
                }
            }
        }
        this.burning      = false;
        this.alreadyBurnt = false;
        return(transform);
    }
Esempio n. 8
0
 private void SpawnBird(GameObject closestPlayer)
 {
     if (!this.pause)
     {
         GameObject gameObject = null;
         int        num        = Mathf.FloorToInt((float)UnityEngine.Random.Range(0, this.myBirds.Length));
         int        num2       = 0;
         if (this.myBirds.Length == 0)
         {
             return;
         }
         if (closestPlayer == null)
         {
             return;
         }
         if (Scene.SceneTracker.allPlayersInCave.Contains(closestPlayer))
         {
             return;
         }
         while (gameObject == null)
         {
             if (!this.myBirds[num].activeSelf)
             {
                 gameObject = this.myBirds[num];
             }
             num = ((num + 1 < this.myBirds.Length) ? (num + 1) : 0);
             num2++;
             if (num2 >= this.myBirds.Length)
             {
                 return;
             }
         }
         lb_Bird component = gameObject.GetComponent <lb_Bird>();
         if (this.sceneInfo.beachMarkers.Count > 0)
         {
             int num3 = 0;
             for (int i = 0; i < this.sceneInfo.beachMarkers.Count; i++)
             {
                 if ((this.sceneInfo.beachMarkers[i].transform.position - closestPlayer.transform.position).sqrMagnitude < 14400f)
                 {
                     num3++;
                 }
             }
             if (num3 == 0 && component.typeSeagull)
             {
                 return;
             }
             if (num3 > 0 && (component.typeSparrow || component.typeCrow || component.typeBlueBird || component.typeRedBird))
             {
                 return;
             }
         }
         gameObject.transform.position = this.FindPositionOffCamera(closestPlayer);
         if (gameObject.transform.position == Vector3.zero)
         {
             return;
         }
         gameObject.SetActive(true);
         if (gameObject.GetComponent <BoltEntity>() && BoltNetwork.isRunning)
         {
             lb_BirdController.AttachBirdToNetwork(gameObject);
         }
         this.activeBirds++;
         this.BirdFindTarget(gameObject);
     }
 }
Esempio n. 9
0
    private IEnumerator StartBirdsRoutine()
    {
        base.InvokeRepeating("checkHandConditions", 1f, 8f);
        if (BoltNetwork.isClient)
        {
            yield break;
        }
        this.rg        = AstarPath.active.astarData.recastGraph;
        this.layerMask = 513;
        if (GameSetup.IsHardSurvivalMode)
        {
            this.idealNumberOfBirds = 4;
        }
        base.InvokeRepeating("updateBirdAmounts", 1f, 120f);
        this.initIdealBirds = this.idealNumberOfBirds;
        this.initMaxBirds   = this.maximumNumberOfBirds;
        this.modIdealBirds  = this.idealNumberOfBirds;
        this.modMaxBirds    = this.maximumNumberOfBirds;
        this.sceneInfo      = Scene.SceneTracker;
        if (this.idealNumberOfBirds >= this.maximumNumberOfBirds)
        {
            this.idealNumberOfBirds = this.maximumNumberOfBirds - 1;
        }
        this.myBirds = new GameObject[this.maximumNumberOfBirds];
        int nextVal = 0;

        for (int i = 0; i < this.myBirds.Length; i++)
        {
            GameObject bird = UnityEngine.Object.Instantiate <GameObject>(this.birdPrefabs[nextVal], Vector3.zero, Quaternion.identity);
            this.myBirds[i] = bird;
            nextVal++;
            if (nextVal == this.birdPrefabs.Length)
            {
                nextVal = 0;
            }
        }
        for (int j = 0; j < this.myBirds.Length; j++)
        {
            lb_Bird component = this.myBirds[j].GetComponent <lb_Bird>();
            if (component)
            {
                component.SetController(this);
            }
            this.myBirds[j].SetActive(false);
        }
        if (!base.IsInvoking("UpdateBirds"))
        {
            if (GameSetup.IsHardSurvivalMode)
            {
                base.InvokeRepeating("UpdateBirds", 10f, 30f);
            }
            else
            {
                base.InvokeRepeating("UpdateBirds", 10f, 5f);
            }
        }
        base.StopCoroutine("UpdateTargets");
        this.birdPerchTargets.Clear();
        this.birdGroundTargets.Clear();
        base.StartCoroutine("UpdateTargets");
        yield return(null);

        yield break;
    }
Esempio n. 10
0
 void Start()
 {
     gameController = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameSettings>();
     birdController = this.gameObject.GetComponent <lb_Bird>();
 }
        public override void OnEvent(PlayerHitEnemy ev)
        {
            //this needed to be changed.
            //the command would send damage using hitReal - pure damage.
            //this made clients attack ignore armor and deal too much dmg
            if (!this.ValidateSender(ev, SenderTypes.Any))
            {
                return;
            }
            if (!ev.Target)
            {
                return;
            }
            if (ev.Hit == 0)
            {
                return;
            }
            try
            {
                if (EnemyHealth.CurrentAttacker == null)
                {
                    EnemyHealth.CurrentAttacker = ev.Target;
                }
                var packed = ev.Target.networkId.PackedValue;
                if (EnemyManager.hostDictionary.ContainsKey(packed))
                {
                    var enemy = EnemyManager.hostDictionary[packed];
                    if (ev.explosion)
                    {
                        enemy.HealthScript.Explosion(-1);
                    }
                    if (ev.Burn)
                    {
                        enemy.HealthScript.Burn();
                    }
                    if (ev.getAttackerType == DamageMath.SILENTattackerType)
                    {
                        //ghost hit
                        float damage = BitConverter.ToSingle(BitConverter.GetBytes(ev.Hit), 0);
                        enemy.HitPhysicalSilent(damage);
                    }
                    else if (ev.getAttackerType == DamageMath.SILENTattackerTypeMagic)
                    {
                        //ghost hit
                        float damage = BitConverter.ToSingle(BitConverter.GetBytes(ev.Hit), 0);
                        enemy.HitMagic(damage);
                    }
                    else if (ev.getAttackerType == DamageMath.PURE)
                    {
                        float damage = BitConverter.ToSingle(BitConverter.GetBytes(ev.Hit), 0);
                        enemy.HitPure(damage);
                    }
                    else
                    {
                        if (ev.Hit > 0)
                        {
                            float damage = ev.getAttackerType >= DamageMath.CONVERTEDFLOATattackerType ? BitConverter.ToSingle(BitConverter.GetBytes(ev.Hit), 0) : ev.Hit;
                            if (ev.getAttackerType >= DamageMath.CONVERTEDFLOATattackerType)
                            {
                                ev.getAttackerType -= DamageMath.CONVERTEDFLOATattackerType;
                            }
                            //just in case i ever need this
                            //this is how to get the player object which raised the event (ev.RaisedBy.UserData as BoltEntity)
                            enemy.HealthScript.getAttackDirection(ev.getAttackerType);
                            var attackerGO = (ev.RaisedBy.UserData as BoltEntity).gameObject;
                            enemy.setup.search.switchToNewTarget(attackerGO);
                            enemy.setup.hitReceiver.getAttackDirection(ev.getAttackDirection);
                            enemy.setup.hitReceiver.getCombo(ev.getCombo);
                            enemy.HealthScript.takeDamage(ev.takeDamage);
                            enemy.HealthScript.setSkinDamage(1);
                            enemy.HitPhysical(damage);
                        }
                        else
                        {
                            ModAPI.Console.Write("The good armor reduction");
                            enemy.ReduceArmor(-ev.Hit);
                        }
                    }
                    return;
                }

                //F**k all of this spaghetti below
                lb_Bird   component           = ev.Target.GetComponent <lb_Bird>();
                Fish      componentInChildren = ev.Target.GetComponentInChildren <Fish>();
                Transform transform;
                if (componentInChildren)
                {
                    transform = componentInChildren.transform;
                }
                else if (ev.Target.GetComponent <animalHealth>())
                {
                    transform = ev.Target.transform;
                }
                else if (component)
                {
                    transform = component.transform;
                }
                else
                {
                    EnemyHealth componentInChildren2 = ev.Target.GetComponentInChildren <EnemyHealth>();
                    transform = componentInChildren2 ? componentInChildren2.transform : ev.Target.transform.GetChild(0);
                }
                if (ev.getAttacker == 10 && ev.Weapon)
                {
                    ArrowDamage componentInChildren3 = ev.Weapon.GetComponentInChildren <ArrowDamage>();
                    if (componentInChildren3.Live)
                    {
                        arrowStickToTarget componentInChildren4 = transform.GetComponentInChildren <arrowStickToTarget>();
                        Transform          target = transform;
                        if (componentInChildren4)
                        {
                            target = componentInChildren4.transform;
                        }
                        componentInChildren3.CheckHit(Vector3.zero, target, false, transform.GetComponent <Collider>());
                    }
                }
                if (ev.explosion)
                {
                    transform.SendMessage("Explosion", -1, SendMessageOptions.DontRequireReceiver);
                }
                if (ev.HitHead)
                {
                    transform.SendMessage("HitHead", SendMessageOptions.DontRequireReceiver);
                }
                if (ev.getStealthAttack)
                {
                    transform.SendMessage("getStealthAttack", SendMessageOptions.DontRequireReceiver);
                }
                float dmg = ev.getAttackerType >= DamageMath.CONVERTEDFLOATattackerType ? BitConverter.ToSingle(BitConverter.GetBytes(ev.Hit), 0) : ev.Hit;
                if (ev.hitFallDown)
                {
                    mutantHitReceiver componentInChildren5 = transform.GetComponentInChildren <mutantHitReceiver>();
                    if (componentInChildren5)
                    {
                        componentInChildren5.sendHitFallDown(dmg);
                    }
                }
                else
                {
                    if (ev.Hit > 0)
                    {
                        transform.SendMessage("getAttacker", (ev.RaisedBy.UserData as BoltEntity).gameObject, SendMessageOptions.DontRequireReceiver);
                        transform.SendMessage("getAttackerType", ev.getAttackerType, SendMessageOptions.DontRequireReceiver);
                        transform.SendMessage("getAttackDirection", ev.getAttackDirection, SendMessageOptions.DontRequireReceiver);
                        transform.SendMessage("getCombo", ev.getCombo, SendMessageOptions.DontRequireReceiver);
                        transform.SendMessage("takeDamage", ev.takeDamage, SendMessageOptions.DontRequireReceiver);
                        transform.SendMessage("setSkinDamage", UnityEngine.Random.Range(0, 3), SendMessageOptions.DontRequireReceiver);
                        transform.SendMessage("ApplyAnimalSkinDamage", ev.getAttackDirection, SendMessageOptions.DontRequireReceiver);
                        transform.SendMessage("Hit", dmg, SendMessageOptions.DontRequireReceiver);
                        if (ev.HitAxe)
                        {
                            transform.SendMessage("HitAxe", SendMessageOptions.DontRequireReceiver);
                        }
                        if (ev.Burn)
                        {
                            transform.SendMessage("Burn", SendMessageOptions.DontRequireReceiver);
                        }
                    }
                    else
                    {
                        ModAPI.Console.Write("The bad armor reduction");
                        transform.SendMessage("ReduceArmor", -dmg, SendMessageOptions.DontRequireReceiver);
                    }
                }
            }
            finally
            {
                EnemyHealth.CurrentAttacker = null;
            }
        }