Exemplo n.º 1
0
    private void Update()
    {
        Ray        ray = FPSCamera.ScreenPointToRay(new Vector2(Screen.width / 2, Screen.height / 2));
        RaycastHit hitInfo;

        if (Input.GetKeyDown(KeyCode.Mouse0))
        {
            if (Physics.Raycast(ray, out hitInfo, weaponRange))
            {
                switch (hitInfo.collider.tag)
                {
                case "Tree":
                    treeHealth = hitInfo.collider.GetComponentInParent <TreeHealth>();
                    AttackTree();
                    break;

                case "Enemy":
                    advancedAI = hitInfo.collider.GetComponent <AdvancedEnemyAI>();
                    AttackEnemy();
                    break;

                default:
                    break;
                }
            }
        }
    }
    private void Update()

    {
        Ray        ray = FPSCamera.ScreenPointToRay(new Vector2(Screen.width / 2, Screen.height / 2));
        RaycastHit hitInfo;

        if (Physics.Raycast(ray, out hitInfo, attackDistance))
        {
            if (hitInfo.collider.tag == "TreeCollider")

            {
                treeHealth = hitInfo.collider.GetComponentInParent <TreeHealth>();
            }
        }
        Debug.DrawRay(ray.origin, ray.direction * attackDistance, Color.red);



        woodBarShowTimmer -= Time.deltaTime;



        if (Input.GetMouseButton(0))
        {
            StartCoroutine(Wait());
        }



        if (woodBarShowTimmer <= 0)
        {
            NotWoodBar();
        }
    }
Exemplo n.º 3
0
 public static void Prefix(ref TreeHealth __instance)
 {
     if (Menu.InstantTree)
     {
         __instance.Health = 1;
     }
 }
Exemplo n.º 4
0
    private void FixedUpdate()
    {
        if (treeToAttack != null)
        {
            if (!treeToAttack.GetIsPlayerOnTree())
            {
                treeToAttack = null;
            }
        }
        else
        {
            EnableWalkingAndDisableAttacking();
        }

        if (readyToAttack && (treeToAttack != null))
        {
            AttackTree();
        }

        if (health <= 0 && !destructionSignaled)
        {
            DestroyMonster(false);
        }

        if (EndGameDetection.endgameTriggered)
        {
            DestroyMonster(true);
        }
    }
Exemplo n.º 5
0
    public override void OnEvent(HitTree evnt)
    {
        if (!this.ValidateSender(evnt, SenderTypes.Any))
        {
            return;
        }
        CoopTreeId coopTreeId = CoopPlayerCallbacks.AllTrees.FirstOrDefault((CoopTreeId x) => x.Id == evnt.TreeId);

        if (coopTreeId)
        {
            TreeHealth currentView = coopTreeId.GetComponent <LOD_Trees>().CurrentView;
            if (currentView)
            {
                Transform transform = currentView.transform.Find(evnt.ChunkParent);
                if (transform)
                {
                    Transform transform2 = transform.Find("TreeDmg" + evnt.ChunkParent);
                    if (transform2)
                    {
                        transform2.SendMessage("ActivateFake", evnt.ChunkId);
                    }
                }
            }
        }
    }
Exemplo n.º 6
0
    private void Update()
    {
        Ray        ray = FPSCamera.ScreenPointToRay(new Vector2(Screen.width / 2, Screen.height / 2));
        RaycastHit hitInfo;

        Debug.DrawRay(ray.origin, ray.direction * weaponRange, Color.green);

        if (Input.GetKeyDown(KeyCode.Mouse0))
        {
            if (Physics.Raycast(ray, out hitInfo, weaponRange))
            {
                if (hitInfo.collider.tag == "Tree") // Checks if the tree is hit and performs function for the tree
                {
                    treeHealth = hitInfo.collider.GetComponentInParent <TreeHealth>();
                    AttackTree();
                }

                else if (hitInfo.collider.tag == "Zombie")                         // Checks if the tagged Zombie is hit
                {
                    zombieAI = hitInfo.collider.GetComponent <AdvancedZombieAI>(); // Finds the script component called "BasicAI"
                    AttackEnemy();
                }
            }
        }
    }
Exemplo n.º 7
0
 private void OnTriggerExit(Collider collision)
 {
     if (collision.tag == "collision")
     {
         healthText.enabled = false;
         tree = null;
     }
 }
Exemplo n.º 8
0
 private void OnTriggerExit(Collider collision)
 {
     if (collision.tag == "Tree")
     {
         treeToAttack  = null;
         readyToAttack = false;
     }
 }
Exemplo n.º 9
0
 private void OnTriggerEnter(Collider collision)
 {
     if (collision.tag == "Tree")
     {
         tree = collision.GetComponent <TreeHealth>();
         healthText.enabled = true;
         healthText.text    = "Tree Health: " + tree.GetHealth();
     }
 }
Exemplo n.º 10
0
    // Use this for initialization
    void Start()
    {
        th       = GameObject.FindGameObjectWithTag("Tree").GetComponent <TreeHealth>();
        gm       = GameObject.FindGameObjectWithTag("GameManager").GetComponent <GameManager>();
        spawners = GameObject.FindGameObjectsWithTag("SoulSpawner");

        textTyper          = typerGameObject.GetComponent <TextTyper>();
        nextWaveLabelText  = nextWaveLabel.GetComponent <Text>();
        nextWaveNumberText = nextWaveNumber.GetComponent <Text>();
    }
Exemplo n.º 11
0
    // Use this for initialization

    private void Start()
    {
        waveCounter   = 1;
        scoreTextComp = scoreText.GetComponent <Text>();
        evilsTextComp = evilsGameObject.GetComponent <Text>();
        sp            = SoulSpawner.GetComponent <SoulSpawn>();
        th            = GameObject.FindGameObjectWithTag("Tree").GetComponent <TreeHealth>();
        spawners      = GameObject.FindGameObjectsWithTag("SoulSpawner");
        canQuit       = false;
    }
Exemplo n.º 12
0
    private void lookAtExplosion(Vector3 position)
    {
        Vector3 b = new Vector3(1f, 0f, 1f);

        if (!this._idleIfPresent && Vector3.Distance(Vector3.Scale(position, b), Vector3.Scale(base.transform.position, b)) < 3.5f)
        {
            if (LocalPlayer.Sfx)
            {
                LocalPlayer.Sfx.PlayBreakWood(base.gameObject);
            }
            LOD_Stump componentInParent = base.GetComponentInParent <LOD_Stump>();
            LOD_Trees lod_Trees         = (!componentInParent) ? base.GetComponentInParent <LOD_Trees>() : componentInParent.transform.parent.GetComponent <LOD_Trees>();
            if (lod_Trees)
            {
                if (componentInParent && componentInParent.Pool.IsSpawned(base.transform))
                {
                    base.transform.parent = componentInParent.Pool.transform;
                    componentInParent.Pool.Despawn(base.transform);
                }
                if (!BoltNetwork.isRunning)
                {
                    this.Finalize(lod_Trees, (!componentInParent) ? base.gameObject : componentInParent.gameObject);
                }
                else
                {
                    RemoveStump removeStump = RemoveStump.Create(GlobalTargets.OnlyServer);
                    removeStump.TargetTree = lod_Trees.GetComponent <BoltEntity>();
                    if (this._blownUpStump)
                    {
                        removeStump.Position           = base.transform.position;
                        removeStump.Rotation           = base.transform.rotation;
                        removeStump.CutUpStumpPrefabId = this._blownUpStump.GetComponent <BoltEntity>().prefabId;
                    }
                    removeStump.Send();
                    this.Finalize((!BoltNetwork.isServer) ? null : lod_Trees, (!componentInParent) ? base.gameObject : componentInParent.gameObject);
                }
            }
            else
            {
                TreeHealth componentInParent2 = base.GetComponentInParent <TreeHealth>();
                if (componentInParent2 && componentInParent2.LodTree)
                {
                    if (BoltNetwork.isRunning)
                    {
                        CoopTreeId component = componentInParent2.LodTree.GetComponent <CoopTreeId>();
                        if (component)
                        {
                            component.Goto_Removed();
                        }
                    }
                    this.Finalize(componentInParent2.LodTree, componentInParent2.gameObject);
                }
            }
        }
    }
Exemplo n.º 13
0
    public IEnumerator SetTarget(Transform target, float wait = 1f)
    {
        yield return(new WaitForSeconds(wait));

        treeHealth = target.GetComponent <TreeHealth>();

        navMeshAgent.SetDestination(target.position);
        treeTransform = target;


        finding = false;
    }
Exemplo n.º 14
0
    private void SpawnCutTree()
    {
        if (this.cut)
        {
            return;
        }
        this.cut = UnityEngine.Object.Instantiate <GameObject>(this.NetworkPrefab, base.transform.position, base.transform.rotation);
        TreeHealth component = this.cut.GetComponent <TreeHealth>();

        component.LodEntity = base.entity;
        component.SetLodBase(this.lod);
        this.cut_chunks = (from x in this.cut.GetComponentsInChildren <TreeCutChunk>()
                           orderby int.Parse(x.transform.parent.gameObject.name)
                           select x).ToArray <TreeCutChunk>();
    }
Exemplo n.º 15
0
    private void CutDownExplosion()
    {
        if (BoltNetwork.isRunning)
        {
            return;
        }
        this.Trunk = (GameObject)UnityEngine.Object.Instantiate(this.Trunk, base.transform.position, base.transform.rotation);
        if (!this.dontScaleTrunk)
        {
            this.Trunk.transform.localScale = base.transform.localScale;
        }
        TreeHealth component = this.Trunk.GetComponent <TreeHealth>();

        component.destroyCutChunks();
        component.SetLodBase(this.LodTree);
        component.CutDown();
        UnityEngine.Object.Destroy(base.gameObject);
    }
Exemplo n.º 16
0
    private void lookAtExplosion(Vector3 position)
    {
        Vector3 b = new Vector3(1f, 0f, 1f);

        if (!this._idleIfPresent && !BoltNetwork.isClient && Vector3.Distance(Vector3.Scale(position, b), Vector3.Scale(base.transform.position, b)) < 3.5f)
        {
            LocalPlayer.Sfx.PlayBreakWood(base.gameObject);
            LOD_Stump componentInParent = base.GetComponentInParent <LOD_Stump>();
            if (componentInParent)
            {
                LOD_Trees component = componentInParent.transform.parent.GetComponent <LOD_Trees>();
                if (component.Pool.IsSpawned(base.transform))
                {
                    base.transform.parent = component.Pool.transform;
                    component.Pool.Despawn(base.transform);
                }
                if (BoltNetwork.isRunning)
                {
                    CoopTreeId component2 = component.GetComponent <CoopTreeId>();
                    if (component2)
                    {
                        component2.Goto_Removed();
                    }
                }
                this.Finalize(component, componentInParent.gameObject);
            }
            else
            {
                TreeHealth componentInParent2 = base.GetComponentInParent <TreeHealth>();
                if (componentInParent2 && componentInParent2.LodTree)
                {
                    if (BoltNetwork.isRunning)
                    {
                        CoopTreeId component3 = componentInParent2.LodTree.GetComponent <CoopTreeId>();
                        if (component3)
                        {
                            component3.Goto_Removed();
                        }
                    }
                    this.Finalize(componentInParent2.LodTree, componentInParent2.gameObject);
                }
            }
        }
    }
Exemplo n.º 17
0
 private void CheckTargetingTree(TreeHealth treeHealth)
 {
     if (treeHealth == null)
     {
         this.RevertGhostPosition();
         this.Reset();
     }
     else
     {
         Transform transform = treeHealth.transform.Find("TreeHouseBuild");
         if (transform && this.Target != transform)
         {
             this.Lock();
             this.Target = transform;
             this.CreateScript.BuildingPlacer.Locked = false;
             this.CreateScript.TargetTree            = transform;
         }
     }
 }
Exemplo n.º 18
0
    private void Update()
    {
        Ray        ray = FPSCamera.ScreenPointToRay(new Vector2(Screen.width / 2, Screen.height / 2));
        RaycastHit hitInfo;

        Debug.DrawRay(ray.origin, ray.direction * weaponRange, Color.green);

        if (Input.GetKeyDown(KeyCode.Mouse0))
        {
            if (Physics.Raycast(ray, out hitInfo, weaponRange))
            {
                if (hitInfo.collider.tag == "Tree")
                {
                    treeHealth = hitInfo.collider.GetComponent <TreeHealth>();
                    AttackTree();
                }
            }
        }
    }
Exemplo n.º 19
0
    private void State_Destroyed()
    {
        base.state.FallingTransform.SetTransforms(null);
        if (base.entity.isOwner)
        {
            if (this.lod)
            {
                this.lod.enabled = false;
            }
            return;
        }
        bool flag = !this.fall;

        if (this.fall)
        {
            this.fall.BroadcastMessage("ActivateLeafParticles", SendMessageOptions.DontRequireReceiver);
            UnityEngine.Object.Destroy(this.fall);
            this.fall = null;
        }
        if (this.lod)
        {
            this.lod.enabled   = false;
            this.lod.DontSpawn = true;
            if (this.lod.CurrentLodTransform)
            {
                UnityEngine.Object.Destroy(this.lod.CurrentLodTransform.gameObject);
            }
            if (flag)
            {
                this.lod.SpawnStumpLod();
            }
            else if (this.cut != null)
            {
                TreeHealth component = this.cut.GetComponent <TreeHealth>();
                if (component)
                {
                    component.DestroyTrunk();
                }
            }
        }
        this.FinalCleanup();
    }
Exemplo n.º 20
0
 private void LocalizedHit(LocalizedHitData data)
 {
     if (!this._idleIfPresent)
     {
         if (BoltNetwork.isRunning)
         {
             CoopTreeId coopTreeId = base.GetComponentInParent <CoopTreeId>();
             if (!coopTreeId)
             {
                 TreeHealth componentInParent = base.GetComponentInParent <TreeHealth>();
                 if (componentInParent && componentInParent.LodTree)
                 {
                     coopTreeId = componentInParent.LodTree.GetComponent <CoopTreeId>();
                 }
             }
             if (coopTreeId && coopTreeId.state.State != 3)
             {
                 return;
             }
         }
         else if (this._tree)
         {
             if (this._tree.Health > 0)
             {
                 return;
             }
         }
         else if (this._coolDown != 0f)
         {
             return;
         }
         Prefabs.Instance.SpawnHitPS(HitParticles.Wood, data._position, Quaternion.LookRotation(base.transform.position - data._position));
         if (this._hp > 0f)
         {
             this._hp -= data._damage;
             if (this._hp <= 0f)
             {
                 this.lookAtExplosion(base.transform.position);
             }
         }
     }
 }
Exemplo n.º 21
0
    private void Update()
    {
        Ray        ray = FPCamera.ScreenPointToRay(new Vector2(Screen.width / 2, Screen.height / 2));
        RaycastHit hitInfo;

        if (Input.GetKeyDown(KeyCode.Mouse0))
        {
            if (Physics.Raycast(ray, out hitInfo, weaponRange))
            {
                if (hitInfo.collider.tag == "Tree")
                {
                    ;
                }
                {
                    treeHealth = hitInfo.collider.GetComponentInParent <TreeHealth>();
                    AttackTree();
                }
            }
        }
    }
Exemplo n.º 22
0
    private void OnTriggerEnter(Collider collision)
    {
        if (collision.tag == "Tree")
        {
            treeToAttack = collision.GetComponent <TreeHealth>();
            if (treeToAttack.GetIsPlayerOnTree())
            {
                //TODO: disable monster movement and switch animation to attack

                readyToAttack = true;
            }
        }

        if (collision.tag == "Bullet")
        {
            if (health > 0)
            {
                TakeDamage();
            }
        }
    }
Exemplo n.º 23
0
    public void DoSpawnCutTree()
    {
        if (BoltNetwork.isRunning)
        {
            return;
        }
        EventInstance windEvent = TreeWindSfx.BeginTransfer(base.transform);

        this.Trunk = (GameObject)UnityEngine.Object.Instantiate(this.Trunk, base.transform.position, base.transform.rotation);
        if (!this.dontScaleTrunk)
        {
            this.Trunk.transform.localScale = base.transform.localScale;
        }
        TreeHealth component = this.Trunk.GetComponent <TreeHealth>();

        component.SetLodBase(this.LodTree);
        UnityEngine.Object.Destroy(base.gameObject);
        PrefabId log = BoltPrefabs.Log;

        TreeWindSfx.CompleteTransfer(this.Trunk.transform, windEvent);
    }
Exemplo n.º 24
0
    private IEnumerator validateCurrentTree(GameObject tree)
    {
        TreeHealth th = tree.GetComponent <TreeHealth>();

        if (!th)
        {
            yield break;
        }
        if (th.LodTree)
        {
            LOD_Trees lt = th.LodTree.GetComponent <LOD_Trees>();
            while (lt.CurrentLodTransform != null && lt.enabled)
            {
                yield return(null);
            }
            this.pmBase.SendEvent("cancelTreeClimb");
        }
        yield return(null);

        yield break;
    }
Exemplo n.º 25
0
    public void CheckHit(Vector3 position, Transform target, bool isTrigger, Collider targetCollider)
    {
        if (this.ignoreCollisionEvents(targetCollider) && !target.CompareTag("enemyRoot"))
        {
            return;
        }
        if (!isTrigger)
        {
            Molotov componentInParent = base.transform.GetComponentInParent <Molotov>();
            if (componentInParent)
            {
                componentInParent.IncendiaryBreak();
            }
        }
        bool headDamage = false;

        if (target.gameObject.layer == LayerMask.NameToLayer("Water"))
        {
            FMODCommon.PlayOneshotNetworked(this.hitWaterEvent, base.transform, FMODCommon.NetworkRole.Any);
        }
        else if (target.CompareTag("SmallTree"))
        {
            FMODCommon.PlayOneshotNetworked(this.hitBushEvent, base.transform, FMODCommon.NetworkRole.Any);
        }
        if (target.CompareTag("PlaneHull"))
        {
            FMODCommon.PlayOneshotNetworked(this.hitMetalEvent, base.transform, FMODCommon.NetworkRole.Any);
        }
        if (target.CompareTag("Tree") || target.root.CompareTag("Tree") || target.CompareTag("Target"))
        {
            if (this.spearType)
            {
                base.StartCoroutine(this.HitTree(this.hit.point - base.transform.forward * 2.1f));
            }
            else if (this.hitPointUpdated)
            {
                base.StartCoroutine(this.HitTree(this.hit.point - base.transform.forward * 0.35f));
            }
            else
            {
                base.StartCoroutine(this.HitTree(base.transform.position - base.transform.forward * 0.35f));
            }
            this.disableLive();
            if (target.CompareTag("Tree") || target.root.CompareTag("Tree"))
            {
                TreeHealth component = target.GetComponent <TreeHealth>();
                if (!component)
                {
                    component = target.root.GetComponent <TreeHealth>();
                }
                if (component)
                {
                    component.LodTree.AddTreeCutDownTarget(base.gameObject);
                }
            }
        }
        else if (target.CompareTag("enemyCollide") || target.tag == "lb_bird" || target.CompareTag("animalCollide") || target.CompareTag("Fish") || target.CompareTag("enemyRoot") || target.CompareTag("animalRoot"))
        {
            bool flag  = target.tag == "lb_bird" || target.CompareTag("lb_bird");
            bool flag2 = target.CompareTag("Fish");
            bool flag3 = target.CompareTag("animalCollide") || target.CompareTag("animalRoot");
            arrowStickToTarget arrowStickToTarget = target.GetComponent <arrowStickToTarget>();
            if (!arrowStickToTarget)
            {
                arrowStickToTarget = target.root.GetComponentInChildren <arrowStickToTarget>();
            }
            if (!this.spearType && !this.flintLockAmmoType && !flag2)
            {
                if (arrowStickToTarget && arrowStickToTarget.enabled)
                {
                    if (flag)
                    {
                        EventRegistry.Achievements.Publish(TfEvent.Achievements.BirdArrowKill, null);
                    }
                    arrowStickToTarget.CreatureType(flag3, flag, flag2);
                    if (BoltNetwork.isRunning)
                    {
                        if (this.at && this.at._boltEntity && this.at._boltEntity.isAttached && this.at._boltEntity.isOwner)
                        {
                            headDamage = arrowStickToTarget.stickArrowToNearestBone(base.transform);
                        }
                    }
                    else
                    {
                        headDamage = arrowStickToTarget.stickArrowToNearestBone(base.transform);
                    }
                }
                if (arrowStickToTarget)
                {
                    base.Invoke("destroyMe", 0.1f);
                }
            }
            base.StartCoroutine(this.HitAi(target, flag || flag3, headDamage));
            if (flag2)
            {
                base.StartCoroutine(this.HitFish(target, this.hit.point - base.transform.forward * 0.35f));
            }
            this.disableLive();
        }
        else if (target.CompareTag("PlayerNet"))
        {
            if (BoltNetwork.isRunning)
            {
                BoltEntity boltEntity = target.GetComponentInParent <BoltEntity>();
                if (!boltEntity)
                {
                    boltEntity = target.GetComponent <BoltEntity>();
                }
                if (boltEntity)
                {
                    HitPlayer.Create(boltEntity, EntityTargets.OnlyOwner).Send();
                    this.disableLive();
                }
            }
        }
        else if (target.CompareTag("TerrainMain") && !LocalPlayer.IsInCaves)
        {
            if (this.ignoreTerrain)
            {
                this.ignoreTerrain = false;
                base.StartCoroutine(this.RevokeIgnoreTerrain());
            }
            else
            {
                if (this.spearType)
                {
                    if (this.bodyCollider)
                    {
                        this.bodyCollider.isTrigger = true;
                    }
                    base.StartCoroutine(this.HitStructure(base.transform.position - base.transform.forward * 2.1f, false));
                }
                else
                {
                    Vector3 position2 = base.transform.position - base.transform.forward * -0.8f;
                    float   num       = Terrain.activeTerrain.SampleHeight(base.transform.position) + Terrain.activeTerrain.transform.position.y;
                    if (base.transform.position.y < num)
                    {
                        position2.y = num + 0.5f;
                    }
                    base.StartCoroutine(this.HitStructure(position2, false));
                }
                this.disableLive();
                FMODCommon.PlayOneshotNetworked(this.hitGroundEvent, base.transform, FMODCommon.NetworkRole.Any);
            }
        }
        else if (target.CompareTag("structure") || target.CompareTag("jumpObject") || target.CompareTag("SLTier1") || target.CompareTag("SLTier2") || target.CompareTag("SLTier3") || target.CompareTag("UnderfootWood"))
        {
            if (target.transform.parent && (target.transform.parent.GetComponent <StickFenceChunkArchitect>() || target.transform.parent.GetComponent <BoneFenceChunkArchitect>()))
            {
                return;
            }
            if (!isTrigger)
            {
                if (this.spearType)
                {
                    base.StartCoroutine(this.HitStructure(this.hit.point - base.transform.forward * 2.1f, true));
                }
                else
                {
                    base.StartCoroutine(this.HitStructure(this.hit.point - base.transform.forward * 0.35f, true));
                }
                this.disableLive();
            }
        }
        else if (target.CompareTag("CaveDoor"))
        {
            this.ignoreTerrain = true;
            Physics.IgnoreCollision(base.GetComponent <Collider>(), Terrain.activeTerrain.GetComponent <Collider>(), true);
        }
        else if (this.flintLockAmmoType && (target.CompareTag("BreakableWood") || target.CompareTag("BreakableRock")))
        {
            target.SendMessage("Hit", 40, SendMessageOptions.DontRequireReceiver);
        }
        if (!this.Live)
        {
            this.destroyThisAmmo();
            this.parent.BroadcastMessage("OnArrowHit", SendMessageOptions.DontRequireReceiver);
        }
    }
Exemplo n.º 26
0
        public override void CheckHit(Vector3 position, Transform target, bool isTrigger, Collider targetCollider)
        {
            if (ignoreCollisionEvents(targetCollider) && !target.CompareTag("enemyRoot"))
            {
                return;
            }
            if (!isTrigger)
            {
                Molotov componentInParent = transform.GetComponentInParent <Molotov>();
                if ((bool)componentInParent)
                {
                    componentInParent.IncendiaryBreak();
                }
            }
            bool headDamage = false;

            if (target.gameObject.layer == LayerMask.NameToLayer("Water"))
            {
                FMODCommon.PlayOneshotNetworked(hitWaterEvent, base.transform, FMODCommon.NetworkRole.Any);
            }
            else if (target.CompareTag("SmallTree"))
            {
                FMODCommon.PlayOneshotNetworked(hitBushEvent, base.transform, FMODCommon.NetworkRole.Any);
            }
            if (target.CompareTag("PlaneHull"))
            {
                FMODCommon.PlayOneshotNetworked(hitMetalEvent, base.transform, FMODCommon.NetworkRole.Any);
            }
            if (target.CompareTag("Tree") || target.root.CompareTag("Tree") || target.CompareTag("Target"))
            {
                if (spearType)
                {
                    base.StartCoroutine(HitTree(hit.point - base.transform.forward * 2.1f));
                }
                else if (hitPointUpdated)
                {
                    base.StartCoroutine(HitTree(hit.point - base.transform.forward * 0.35f));
                }
                else
                {
                    base.StartCoroutine(HitTree(base.transform.position - base.transform.forward * 0.35f));
                }
                disableLive();
                if (target.CompareTag("Tree") || target.root.CompareTag("Tree"))
                {
                    TreeHealth component = target.GetComponent <TreeHealth>();
                    if (!(bool)component)
                    {
                        component = target.root.GetComponent <TreeHealth>();
                    }
                    if ((bool)component)
                    {
                        component.LodTree.AddTreeCutDownTarget(base.gameObject);
                    }
                }
            }
            else if (target.CompareTag("enemyCollide") || target.tag == "lb_bird" || target.CompareTag("animalCollide") || target.CompareTag("Fish") || target.CompareTag("enemyRoot") || target.CompareTag("animalRoot"))
            {
                bool flag  = target.tag == "lb_bird" || target.CompareTag("lb_bird");
                bool flag2 = target.CompareTag("Fish");
                bool flag3 = target.CompareTag("animalCollide") || target.CompareTag("animalRoot");
                arrowStickToTarget arrowStickToTarget = target.GetComponent <arrowStickToTarget>();
                if (!(bool)arrowStickToTarget)
                {
                    arrowStickToTarget = target.root.GetComponentInChildren <arrowStickToTarget>();
                }
                if (!spearType && !flintLockAmmoType && !flag2)
                {
                    if (arrowStickToTarget && arrowStickToTarget.enabled)
                    {
                        if (flag)
                        {
                            EventRegistry.Achievements.Publish(TfEvent.Achievements.BirdArrowKill, null);
                        }
                        arrowStickToTarget.CreatureType(flag3, flag, flag2);
                        if (BoltNetwork.isRunning)
                        {
                            if (at && at._boltEntity && at._boltEntity.isAttached && at._boltEntity.isOwner)
                            {
                                headDamage = arrowStickToTarget.stickArrowToNearestBone(base.transform);
                            }
                        }
                        else
                        {
                            headDamage = arrowStickToTarget.stickArrowToNearestBone(base.transform);
                        }
                    }
                    if ((bool)arrowStickToTarget)
                    {
                        base.Invoke("destroyMe", 0.1f);
                    }
                }
                base.StartCoroutine(HitAi(target, flag || flag3, headDamage));
                ModdedPlayer.instance.DoAreaDamage(target.root, damage);
                ModdedPlayer.instance.DoOnHit();

                if (ModdedPlayer.instance.RangedArmorReduction > 0 && target.gameObject.CompareTag("enemyCollide"))
                {
                    if (BoltNetwork.isClient)
                    {
                        BoltEntity be = target.GetComponentInParent <BoltEntity>();
                        if (be == null)
                        {
                            be = target.GetComponent <BoltEntity>();
                        }
                        if (be != null)
                        {
                            EnemyProgression.ReduceArmor(be, ModdedPlayer.instance.MeleeArmorReduction);
                        }
                    }
                    else
                    {
                        target.transform.SendMessageUpwards("ReduceArmor", ModdedPlayer.instance.MeleeArmorReduction, SendMessageOptions.DontRequireReceiver);
                    }
                }
                if (flag2)
                {
                    base.StartCoroutine(HitFish(target, hit.point - base.transform.forward * 0.35f));
                }
                disableLive();
            }
            else if (target.CompareTag("PlayerNet"))
            {
                if (BoltNetwork.isRunning)
                {
                    BoltEntity boltEntity = target.GetComponentInParent <BoltEntity>();
                    if (!(bool)boltEntity)
                    {
                        boltEntity = target.GetComponent <BoltEntity>();
                    }
                    if (boltEntity && ModSettings.FriendlyFire)
                    {
                        HitPlayer HP = HitPlayer.Create(boltEntity, EntityTargets.Everyone);
                        HP.damage = damage;
                        HP.Send();
                        disableLive();
                    }
                }
            }
            else if (target.CompareTag("TerrainMain") && !LocalPlayer.IsInCaves)
            {
                if (ignoreTerrain)
                {
                    ignoreTerrain = false;
                    base.StartCoroutine(RevokeIgnoreTerrain());
                }
                else
                {
                    if (spearType)
                    {
                        if ((bool)bodyCollider)
                        {
                            bodyCollider.isTrigger = true;
                        }
                        base.StartCoroutine(HitStructure(base.transform.position - base.transform.forward * 2.1f, false));
                    }
                    else
                    {
                        Vector3 position2 = base.transform.position - base.transform.forward * -0.8f;
                        float   num       = Terrain.activeTerrain.SampleHeight(base.transform.position);
                        Vector3 position3 = Terrain.activeTerrain.transform.position;
                        float   num2      = num + position3.y;
                        Vector3 position4 = base.transform.position;
                        if (position4.y < num2)
                        {
                            position2.y = num2 + 0.5f;
                        }
                        base.StartCoroutine(HitStructure(position2, false));
                    }
                    disableLive();
                    FMODCommon.PlayOneshotNetworked(hitGroundEvent, base.transform, FMODCommon.NetworkRole.Any);
                }
            }
            else if (target.CompareTag("structure") || target.CompareTag("jumpObject") || target.CompareTag("SLTier1") || target.CompareTag("SLTier2") || target.CompareTag("SLTier3") || target.CompareTag("UnderfootWood"))
            {
                if ((bool)target.transform.parent)
                {
                    if ((bool)target.transform.parent.GetComponent <StickFenceChunkArchitect>())
                    {
                        return;
                    }
                    if ((bool)target.transform.parent.GetComponent <BoneFenceChunkArchitect>())
                    {
                        return;
                    }
                }
                if (!isTrigger)
                {
                    if (spearType)
                    {
                        base.StartCoroutine(HitStructure(hit.point - base.transform.forward * 2.1f, true));
                    }
                    else
                    {
                        base.StartCoroutine(HitStructure(hit.point - base.transform.forward * 0.35f, true));
                    }
                    disableLive();
                }
            }
            else if (target.CompareTag("CaveDoor"))
            {
                ignoreTerrain = true;
                Physics.IgnoreCollision(base.GetComponent <Collider>(), Terrain.activeTerrain.GetComponent <Collider>(), true);
            }
            else if (flintLockAmmoType && (target.CompareTag("BreakableWood") || target.CompareTag("BreakableRock")))
            {
                target.SendMessage("Hit", 40, SendMessageOptions.DontRequireReceiver);
            }
            if (!Live)
            {
                destroyThisAmmo();
                parent.BroadcastMessage("OnArrowHit", SendMessageOptions.DontRequireReceiver);
            }
        }
Exemplo n.º 27
0
 private void Awake()
 {
     th    = GameObject.FindGameObjectWithTag("Tree").GetComponent <TreeHealth>();
     audio = this.gameObject.GetComponent <AudioSource>();
 }
Exemplo n.º 28
0
 // Use this for initialization
 void Awake()
 {
     healthText         = GameObject.Find("HealthUI").GetComponent <Text>();
     healthText.enabled = false;
     tree = null;
 }
Exemplo n.º 29
0
 private void FixedUpdate()
 {
     if (this._targetObject && !this._noValidTargetObject)
     {
         if (!this._locked && !Grabber.IsFocused && LocalPlayer.Inventory.HasInSlot(this._slot, this._itemId))
         {
             if (Physics.Raycast(LocalPlayer.MainCamTr.position, LocalPlayer.MainCamTr.forward, out this._hit, 10f, this._layerMask.value) && !this._hit.collider.isTrigger)
             {
                 Rigidbody component = this._hit.transform.GetComponent <Rigidbody>();
                 if (!component)
                 {
                     component = this._hit.transform.parent.GetComponent <Rigidbody>();
                 }
                 if (component && component.useGravity)
                 {
                     this._noValidTargetObject = true;
                     return;
                 }
                 if (this._targetObject.CompareTag("trapTrigger"))
                 {
                     this._placeIconSheen.transform.position = this._targetObject.transform.position;
                 }
                 else
                 {
                     this._placeIconSheen.transform.position = this._hit.point + LocalPlayer.MainCamTr.forward * -0.1f;
                 }
                 if (!this._placeIconSheen.activeSelf)
                 {
                     this._placeIconSheen.transform.parent = null;
                     this._placeIconSheen.SetActive(true);
                 }
                 if (TheForest.Utils.Input.GetButtonDown("Craft"))
                 {
                     if (this._playWhooshOnInput)
                     {
                         LocalPlayer.Sfx.PlayWhoosh();
                     }
                     bool flag = true;
                     if (LocalPlayer.ActiveBurnableItem != null)
                     {
                         flag = !LocalPlayer.ActiveBurnableItem.IsUnlit();
                     }
                     if ((this._slot != Item.EquipmentSlot.RightHand) ? LocalPlayer.Inventory.RemoveItem(this._itemId, 1, false, true) : LocalPlayer.Inventory.ShuffleRemoveRightHandItem())
                     {
                         Vector3 forward;
                         if (this._rotationMode == DistractionDevicePlacer.RotationModes.LookAtCenterOfTarget)
                         {
                             forward = this._hit.point - this._hit.transform.position;
                         }
                         else
                         {
                             forward = this._hit.normal;
                         }
                         forward.y = 0f;
                         Vector3 position = this._hit.point;
                         if (this._targetObject.CompareTag("trapTrigger"))
                         {
                             position = this._targetObject.transform.position;
                         }
                         if (BoltNetwork.isRunning && this._spawnMode == DistractionDevicePlacer.SpawnModes.ServerSide)
                         {
                             DropItem dropItem = DropItem.Create(GlobalTargets.OnlyServer);
                             dropItem.PrefabId     = ((!flag) ? this._distractionDevicePrefabUnlit : this._distractionDevicePrefab).GetComponent <BoltEntity>().prefabId;
                             dropItem.Position     = position;
                             dropItem.Rotation     = Quaternion.LookRotation(forward);
                             dropItem.PreSpawned   = null;
                             dropItem.AvoidImpacts = false;
                             dropItem.Send();
                         }
                         else
                         {
                             GameObject gameObject;
                             if (flag)
                             {
                                 gameObject = UnityEngine.Object.Instantiate <GameObject>(this._distractionDevicePrefab, position, Quaternion.LookRotation(forward));
                             }
                             else
                             {
                                 gameObject = UnityEngine.Object.Instantiate <GameObject>(this._distractionDevicePrefabUnlit, position, Quaternion.LookRotation(forward));
                             }
                             if (this._targetObject.CompareTag("Tree") || this._targetObject.transform.root.CompareTag("Tree"))
                             {
                                 TreeHealth component2 = this._targetObject.GetComponent <TreeHealth>();
                                 if (!component2)
                                 {
                                     component2 = this._targetObject.transform.root.GetComponent <TreeHealth>();
                                 }
                                 if (component2 && component2.LodTree)
                                 {
                                     component2.LodTree.AddTreeCutDownTarget(gameObject);
                                 }
                             }
                             if (BoltNetwork.isRunning)
                             {
                                 BoltEntity component3 = BoltNetwork.Attach(gameObject).GetComponent <BoltEntity>();
                                 if (component3 && this._playAudio && WalkmanControler.HasCassetteReady)
                                 {
                                     component3.GetState <IDistractionDevice>().MusicTrack = WalkmanControler.CurrentTrack + 10;
                                 }
                             }
                             else if (this._playAudio)
                             {
                                 EventInstance eventInstance = LocalPlayer.Sfx.RelinquishMusicTrack();
                                 if (eventInstance == null && WalkmanControler.HasCassetteReady)
                                 {
                                     eventInstance = LocalPlayer.Sfx.InstantiateMusicTrack(WalkmanControler.CurrentTrack);
                                 }
                                 if (eventInstance != null)
                                 {
                                     gameObject.SendMessage("ActivateDevice", eventInstance);
                                 }
                                 gameObject.SendMessage("SetPlayerSfx", LocalPlayer.Sfx);
                             }
                         }
                         this._placeIconSheen.SetActive(false);
                         this._placeIconSheen.transform.parent = base.transform;
                         this.Deactivate();
                     }
                 }
             }
         }
         else if (this._placeIconSheen.activeSelf)
         {
             this._placeIconSheen.transform.parent = base.transform;
             this._placeIconSheen.SetActive(false);
         }
     }
     else
     {
         this.Deactivate();
     }
 }
Exemplo n.º 30
0
        public override void CheckHit(Vector3 position, Transform target, bool isTrigger, Collider targetCollider)
        {
            if (alreadyHit.Contains(target))
            {
                return;
            }
            else
            {
                alreadyHit.Add(target);
            }
            if (UpgradePointsMod.instance != null)
            {
                float a = BaseDamage + velocitybonus;

                a *= UpgradePointsMod.instance.ArrowDmg;

                if (UpgradePointsMod.instance.specialUpgrades[28].bought)
                {
                    if (UpgradePointsMod.instance.specialUpgrades[49].bought)
                    {
                        if (UpgradePointsMod.instance.specialUpgrades[50].bought)
                        {
                            if (UpgradePointsMod.instance.specialUpgrades[36].bought)
                            {
                                if (UpgradePointsMod.instance.specialUpgrades[90].bought)
                                {
                                    if (UpgradePointsMod.instance.specialUpgrades[91].bought)
                                    {
                                        if (UpgradePointsMod.instance.specialUpgrades[92].bought)
                                        {
                                            if (UpgradePointsMod.instance.specialUpgrades[93].bought)
                                            {
                                                if (UpgradePointsMod.instance.specialUpgrades[94].bought)
                                                {
                                                    if (UpgradePointsMod.instance.specialUpgrades[95].bought)
                                                    {
                                                        a *= 35;
                                                    }
                                                    else
                                                    {
                                                        a *= 32.5f;
                                                    }
                                                }
                                                else
                                                {
                                                    a *= 30f;
                                                }
                                            }
                                            else
                                            {
                                                a *= 27f;
                                            }
                                        }
                                        else
                                        {
                                            a *= 24f;
                                        }
                                    }
                                    else
                                    {
                                        a *= 20f;
                                    }
                                }
                                else
                                {
                                    a *= 16f;
                                }
                            }
                            else
                            {
                                a *= 8f;
                            }
                        }
                        else
                        {
                            a *= 3f;
                        }
                    }
                    else
                    {
                        a *= 2f;
                    }
                    if (spearType)
                    {
                        if (UpgradePointsMod.instance.specialUpgrades[30].bought)
                        {
                            a *= 3.5f;
                        }
                    }
                    if (UpgradePointsMod.instance.specialUpgrades[29].bought)
                    {
                        if (UpgradePointsMod.instance.specialUpgrades[89].bought)
                        {
                            a *= 1 + UpgradePointsMod.instance.FocusFireStacks * 0.4f;
                        }
                        else
                        {
                            a *= 1 + UpgradePointsMod.instance.FocusFireStacks * 0.25f;
                        }
                    }
                    if (UpgradePointsMod.instance.specialUpgrades[7].bought)
                    {
                        if (StealthCheck.IsHidden)
                        {
                            if (UpgradePointsMod.instance.specialUpgrades[8].bought)
                            {
                                if (UpgradePointsMod.instance.specialUpgrades[10].bought)
                                {
                                    a *= 15;
                                }
                                else
                                {
                                    a *= 5;
                                }
                            }
                            else
                            {
                                a *= 2;
                            }
                        }
                    }
                    a *= BrawlerUpgrade.DamageBonus + 1;

                    if (UpgradePointsMod.instance.specialUpgrades[33].bought)
                    {
                        float dist = Vector3.Distance(startingpos, target.position);
                        dist /= 20; // every 20 meters
                        a     = a * (1 + dist);
                    }
                    if (UpgradePointsMod.instance.specialUpgrades[48].bought)
                    {
                        if (target.CompareTag("enemyCollide"))
                        {
                            if (UpgradePointsMod.instance.ComboStrikeBonusDamage(UpgradePointsMod.StrikeType.Ranged, target.root))
                            {
                                a *= 4;
                            }
                            UpgradePointsMod.instance.AddToComboStrike(UpgradePointsMod.StrikeType.Melee, target.root);
                        }
                    }
                    if (UpgradePointsMod.instance.specialUpgrades[44].bought)
                    {
                        if (CharacterControllerMod.FloatVelocity < 0.1f)
                        {
                            a *= 3;
                        }
                    }
                }
                a     *= UpgradePointsMod.CritBonus();
                damage = Mathf.RoundToInt(a);
            }
            if (UpgradePointsMod.instance.specialUpgrades[29].bought)
            {
                if (UpgradePointsMod.instance.FocusFireTarget == target.gameObject)
                {
                    if (UpgradePointsMod.instance.specialUpgrades[88].bought)
                    {
                        UpgradePointsMod.instance.FocusFireStacks = Mathf.Clamp(UpgradePointsMod.instance.FocusFireStacks + 1, 0, 100);
                    }
                    else
                    {
                        UpgradePointsMod.instance.FocusFireStacks = Mathf.Clamp(UpgradePointsMod.instance.FocusFireStacks + 1, 0, 20);
                    }
                }
                else
                {
                    UpgradePointsMod.instance.FocusFireStacks = 0;
                    UpgradePointsMod.instance.FocusFireTarget = target.gameObject;
                }
            }



            if (!ignoreCollisionEvents(targetCollider))
            {
                if (!isTrigger)
                {
                    Molotov componentInParent = ((Component)base.transform).GetComponentInParent <Molotov>();
                    if ((bool)componentInParent)
                    {
                        componentInParent.IncendiaryBreak();
                    }
                }
                bool headDamage = false;
                if (target.gameObject.layer == LayerMask.NameToLayer("Water"))
                {
                    FMODCommon.PlayOneshotNetworked(hitWaterEvent, base.transform, FMODCommon.NetworkRole.Any);
                }
                else if (target.CompareTag("SmallTree"))
                {
                    FMODCommon.PlayOneshotNetworked(hitBushEvent, base.transform, FMODCommon.NetworkRole.Any);
                }
                if (target.CompareTag("PlaneHull"))
                {
                    FMODCommon.PlayOneshotNetworked(hitMetalEvent, base.transform, FMODCommon.NetworkRole.Any);
                }
                if (target.CompareTag("Tree") || target.root.CompareTag("Tree") || target.CompareTag("Target"))
                {
                    if (spearType)
                    {
                        base.StartCoroutine(HitTree(hit.point - base.transform.forward * 2.1f));
                    }
                    else if (hitPointUpdated)
                    {
                        base.StartCoroutine(HitTree(hit.point - base.transform.forward * 0.35f));
                    }
                    else
                    {
                        base.StartCoroutine(HitTree(base.transform.position - base.transform.forward * 0.35f));
                    }
                    disableLive();
                    if (target.CompareTag("Tree") || target.root.CompareTag("Tree"))
                    {
                        TreeHealth component = ((Component)target).GetComponent <TreeHealth>();
                        if (!(bool)component)
                        {
                            component = ((Component)target.root).GetComponent <TreeHealth>();
                        }
                        if ((bool)component)
                        {
                            component.LodTree.AddTreeCutDownTarget(base.gameObject);
                        }
                    }
                }
                else if (target.CompareTag("enemyCollide") || target.tag == "lb_bird" || target.CompareTag("animalCollide") || target.CompareTag("Fish") || target.CompareTag("enemyRoot") || target.CompareTag("animalRoot"))
                {
                    UpgradePointsMod.instance.DoAreaDamage(target.transform.root, damage);

                    bool flag  = target.tag == "lb_bird" || target.CompareTag("lb_bird");
                    bool flag2 = target.CompareTag("Fish");
                    bool flag3 = target.CompareTag("animalCollide") || target.CompareTag("animalRoot");
                    arrowStickToTarget arrowStickToTarget = ((Component)target).GetComponent <arrowStickToTarget>();
                    if (!(bool)arrowStickToTarget)
                    {
                        arrowStickToTarget = ((Component)target.root).GetComponentInChildren <arrowStickToTarget>();
                    }
                    if (!spearType && !flintLockAmmoType && !flag2)
                    {
                        if ((bool)arrowStickToTarget && arrowStickToTarget.enabled)
                        {
                            if (flag)
                            {
                                EventRegistry.Achievements.Publish(TfEvent.Achievements.BirdArrowKill, null);
                            }
                            arrowStickToTarget.CreatureType(flag3, flag, flag2);
                            if (BoltNetwork.isRunning)
                            {
                                if ((bool)at && (bool)at._boltEntity && at._boltEntity.isAttached && at._boltEntity.isOwner)
                                {
                                    headDamage = arrowStickToTarget.stickArrowToNearestBone(base.transform);
                                }
                            }
                            else
                            {
                                headDamage = arrowStickToTarget.stickArrowToNearestBone(base.transform);
                            }
                        }
                        base.Invoke("destroyMe", 0.1f);
                    }

                    base.StartCoroutine(HitAi(target, flag || flag3, headDamage));
                    if (flag2)
                    {
                        base.StartCoroutine(HitFish(target, hit.point - base.transform.forward * 0.35f));
                    }
                    disableLive();
                }
                else if (target.CompareTag("PlayerNet"))
                {
                    if (BoltNetwork.isRunning)
                    {
                        BoltEntity boltEntity = ((Component)target).GetComponentInParent <BoltEntity>();
                        if (!(bool)boltEntity)
                        {
                            boltEntity = ((Component)target).GetComponent <BoltEntity>();
                        }
                        if ((bool)boltEntity)
                        {
                            HitPlayer.Create(boltEntity, EntityTargets.OnlyOwner).Send();
                            disableLive();
                        }
                    }
                }
                else if (target.CompareTag("TerrainMain") && !LocalPlayer.IsInCaves)
                {
                    if (ignoreTerrain)
                    {
                        ignoreTerrain = false;
                        base.StartCoroutine(RevokeIgnoreTerrain());
                    }
                    else
                    {
                        if (spearType)
                        {
                            if ((bool)bodyCollider)
                            {
                                bodyCollider.isTrigger = true;
                            }
                            base.StartCoroutine(HitStructure(base.transform.position - base.transform.forward * 2.1f, false));
                        }
                        else
                        {
                            Vector3 position2 = base.transform.position - base.transform.forward * -0.8f;
                            float   num       = Terrain.activeTerrain.SampleHeight(base.transform.position);
                            Vector3 position3 = Terrain.activeTerrain.transform.position;
                            float   num2      = num + position3.y;
                            Vector3 position4 = base.transform.position;
                            if (position4.y < num2)
                            {
                                position2.y = num2 + 0.5f;
                            }
                            base.StartCoroutine(HitStructure(position2, false));
                        }
                        disableLive();
                        FMODCommon.PlayOneshotNetworked(hitGroundEvent, base.transform, FMODCommon.NetworkRole.Any);
                    }
                }
                else if (target.CompareTag("structure") || target.CompareTag("jumpObject") || target.CompareTag("SLTier1") || target.CompareTag("SLTier2") || target.CompareTag("SLTier3") || target.CompareTag("UnderfootWood"))
                {
                    if ((bool)target.transform.parent)
                    {
                        if ((bool)((Component)target.transform.parent).GetComponent <StickFenceChunkArchitect>())
                        {
                            return;
                        }
                        if ((bool)((Component)target.transform.parent).GetComponent <BoneFenceChunkArchitect>())
                        {
                            return;
                        }
                    }
                    if (!isTrigger)
                    {
                        if (spearType)
                        {
                            base.StartCoroutine(HitStructure(hit.point - base.transform.forward * 2.1f, true));
                        }
                        else
                        {
                            base.StartCoroutine(HitStructure(hit.point - base.transform.forward * 0.35f, true));
                        }
                        disableLive();
                    }
                }
                else if (target.CompareTag("CaveDoor"))
                {
                    ignoreTerrain = true;
                    Physics.IgnoreCollision(base.GetComponent <Collider>(), ((Component)Terrain.activeTerrain).GetComponent <Collider>(), true);
                }
                else if (flintLockAmmoType && (target.CompareTag("BreakableWood") || target.CompareTag("BreakableRock")))
                {
                    target.SendMessage("Hit", 40, SendMessageOptions.DontRequireReceiver);
                }
                if (!Live)
                {
                    destroyThisAmmo();
                    parent.BroadcastMessage("OnArrowHit", SendMessageOptions.DontRequireReceiver);
                }
            }
        }