Esempio n. 1
0
    void Update()
    {
        MeleeGUI();

        if (!acs.clipping && cInput.GetButtonDown("Fire Weapon") && !isMeleeState)
        {
            dm.DoMeleeAnimation(); //Obviously placeholder.
            GetComponent <AudioSource>().PlayOneShot(meleeSwingSound);
            StartCoroutine(MeleeAction());
        }
    }
Esempio n. 2
0
    //Slam the stock into the enemy's face.
    private void QuickMeleeWithWeapon()
    {
        dm.DoMeleeAnimation();

        Transform theCamera = GeneralVariables.mainPlayerCamera.transform;

        if (Physics.Raycast(theCamera.position, theCamera.forward, out melee, 2f, layersToMelee.value))
        {
            BaseStats bs = melee.collider.GetComponent <BaseStats>();
            Limb      lb = melee.collider.GetComponent <Limb>();
            if (bs == null && lb != null)
            {
                bs = lb.rootStats;
            }

            if (bs != null)
            {
                bool showHitMarker = false;
                int  damage        = Random.Range(50, 55 + 1);

                if (bs.curHealth > 0)
                {
                    showHitMarker = true;
                }

                bool canDamage = true;
                bs.headshot = false;

                if (Topan.Network.isConnected)
                {
                    Topan.NetworkView damageView = bs.GetComponent <Topan.NetworkView>();
                    if (damageView != null)
                    {
                        BotVitals hitBot = bs.GetComponent <BotVitals>();

                        if (GeneralVariables.gameModeHasTeams)
                        {
                            byte targetTeam = /*(hitBot) ? BotManager.allBotPlayers[hitBot.bm.myIndex].team : */ (byte)damageView.owner.GetPlayerData("team", (byte)0);

                            if (targetTeam == (byte)Topan.Network.player.GetPlayerData("team", (byte)0))
                            {
                                if (!friendlyFire)
                                {
                                    canDamage = false;
                                }

                                showHitMarker = false;
                            }
                        }
                        else
                        {
                        }

                        if (canDamage)
                        {
                            if (Topan.Network.isServer && (damageView.ownerID == 0 || hitBot))
                            {
                                bs.ApplyDamageNetwork((byte)Mathf.Clamp(damage, 0, 255), (byte)Topan.Network.player.id, (byte)currentGC.weaponID, (byte)4);
                            }
                            else
                            {
                                damageView.RPC(Topan.RPCMode.Owner, "ApplyDamageNetwork", (byte)Mathf.Clamp(damage, 0, 255), (byte)Topan.Network.player.id, (byte)currentGC.weaponID, (byte)4);
                            }
                        }
                    }
                }
                else
                {
                    bs.ApplyDamageMain(damage, false);
                }

                if (showHitMarker)
                {
                    HitTarget(bs.curHealth <= 0);
                }
            }

            Quaternion rot = Quaternion.LookRotation(melee.normal);

            particleMeleeIndex = 0;
            string surfTag = melee.collider.tag;
            if (surfTag == "Dirt")
            {
                particleMeleeIndex = 1;
            }
            else if (surfTag == "Metal")
            {
                particleMeleeIndex = 2;
            }
            else if (surfTag == "Wood")
            {
                particleMeleeIndex = 3;
            }
            else if (surfTag == "Flesh" || surfTag == "Player - Flesh")
            {
                particleMeleeIndex = 4;
            }
            else if (surfTag == "Water")
            {
                particleMeleeIndex = 5;
            }

            PoolManager.Instance.RequestParticleEmit(particleMeleeIndex, melee.point + (melee.normal * 0.06f), rot);
        }
    }