Ejemplo n.º 1
0
    public void TakeDamage(MPlayerController.DamageInfo damageInfo)
    {
        if (!isServer)
        {
            DebugHUD.Debugg("TDmg not SRV");
            return;
        }

        if (Invulnerable)
        {
            DebugHUD.Debugg("Invul");
            return;
        }

        currentHealth -= damageInfo.amount;
        var testLocalObj = NetworkServer.FindLocalObject(damageInfo.netId);

        DebugHUD.Debugg("damage: " + damageInfo.amount + "src: " + (testLocalObj ? testLocalObj.name : "null"));

        if (currentHealth <= 0)
        {
            currentHealth = maxHealth;
            var damageSource = NetworkServer.FindLocalObject(damageInfo.netId);
            var player       = damageSource.GetComponent <MPlayerController>();
            if (player)
            {
                player.RpcGetAKill();
            }
            //damageInfo.source.RpcGetAKill();
            RpcRespawn();
        }
    }
Ejemplo n.º 2
0
    void RpcRecordScore(Scoreboard.LedgerEntry le)
    {
        setLedgerLocal(le);
        scoreboard.UpdateDisplay(le);

        DebugHUD.Debugg("record Score: " + le.ToString() + " is cli: " + isClient);
        player.testGetNewScore(le);
    }
Ejemplo n.º 3
0
 void CmdEquip(int wIndex)
 {
     DebugHUD.Debugg("cmd equip: " + wIndex);
     for (int i = 0; i < _svLookup.Count; ++i)
     {
         _svLookup[i] = _svLookup[i].CloneEquiped(i == wIndex);
         _svLookup.Dirty(i);
     }
 }
Ejemplo n.º 4
0
 internal void BeDead()
 {
     if (isDead)
     {
         return;
     }
     DebugHUD.Debugg("start dead");
     isDead = true;
     arsenal.loseAll();
     StartCoroutine(goToWaitingRoom());
 }
Ejemplo n.º 5
0
 public void SetDamageSourceId(NetworkInstanceId _netId)
 {
     if (!isServer)
     {
         DebugHUD.Debugg("not server set dmg src id");
         return;
     }
     DebugHUD.Debugg("setting dmg ");
     damage = new MPlayerController.DamageInfo()
     {
         amount = collisionDamage,
         netId  = _netId
     };
 }
Ejemplo n.º 6
0
    private IEnumerator goToWaitingRoom()
    {
        suspendFixedUpdateMovement = true;
        respawner.placeInWaitingRoom(this, () =>
        {
            DebugHUD.Debugg("wroom callback");
            teleportToRespawnLocation(() =>
            {
                isDead = false;
            });
        });
        yield return(new WaitForSeconds(.1f));

        suspendFixedUpdateMovement = false;
    }
Ejemplo n.º 7
0
 private void OnCollisionEnter(Collision collision)
 {
     if (collisionDealsDamage)
     {
         var health = collision.gameObject.GetComponentInParent <Health>(); // collision.collider.GetComponent<Health>();
         if (health)
         {
             DebugHUD.Debugg("BulletColl " + collision.collider.name);
             health.TakeDamage(damage);
             GetComponent <Collider>().enabled      = false;
             GetComponent <Rigidbody>().isKinematic = true;
             GetComponent <Renderer>().enabled      = false;
             if (explodeParticles)
             {
                 explodeParticles.Play();
                 Destroy(gameObject, explodeParticles.main.duration);
             }
             else
             {
                 Destroy(gameObject);
             }
         }
     }
 }
Ejemplo n.º 8
0
 private void debugLE(string s, Scoreboard.LedgerEntry le)
 {
     DebugHUD.Debugg(string.Format("{0} : {1} {2}", (isClient ? "CLI" : "SRV"), s, le.ToString()));
 }
Ejemplo n.º 9
0
 public void dbugWithName(string s)
 {
     DebugHUD.Debugg(string.Format("{0}: {1} {2}", playerData.displayName, cliServer, s));
 }
Ejemplo n.º 10
0
    private void CmdFire(Vector3 origin, Vector3 direction)
    {
        if (!canShoot)
        {
            return;
        }

        Weapon weapon = arsenal.equipedWeapon;

        Assert.IsTrue(weapon);

        //weapon.playFire();

        if (!testMute && aud)
        {
            aud.Play();
        }
        else if (testMute)
        {
            DebugHUD.Debugg("test muted");
        }

        StartCoroutine(shotTimer());

        var destination = origin + direction * 1000f;

        RaycastHit shootHitInfo;

        if (!weapon.bulletPrefab.collisionDealsDamage)
        {
            if (Physics.Raycast(origin, direction, out shootHitInfo, 1000f))
            {
                var health = shootHitInfo.collider.GetComponent <Health>();
                if (health && health != localHealth)
                {
                    health.TakeDamage(new DamageInfo()
                    {
                        amount = 10,
                        netId  = netId
                    });
                }
            }
        }

        var goBullet = (GameObject)Instantiate(
            weapon.bulletPrefab.gameObject,
            bulletSpawn.position,
            bulletSpawn.rotation);

        goBullet.GetComponent <Rigidbody>().velocity = direction;
        var bullet = goBullet.GetComponent <Bullet>();

        bullet.damage = new DamageInfo()
        {
            amount = bullet.collisionDamage,
            netId  = netId
        };
        goBullet.GetComponent <Bullet>().info = new Bullet.BulletInfo()
        {
            destination = destination
        };
        NetworkServer.Spawn(goBullet);

        // Destroy the bullet after 25 seconds
        Destroy(goBullet, 25.0f);
    }
Ejemplo n.º 11
0
    void Update()
    {
        //updateDbugLR();

        if (!isLocalPlayer)
        {
            return;
        }
        if (suspendControls)
        {
            return;
        }

        Vector3 lookTarget;
        Ray     camRay = GetCamRay();

        ikAimWeapon.aimTargetPos = camRay.origin + camRay.direction * 100f;

        if (arsenal.isArmed)
        {
            Ray shootRay = new Ray();
            if (Input.GetMouseButton(0) || Input.GetMouseButtonDown(1))
            {
                shootRay = shootDirection(camRay, out lookTarget);
                ikAimWeapon.aimTargetPos = lookTarget;
            }
            if (Input.GetMouseButtonDown(1))
            {
                thirdCam.shouldAim.Value = true;
            }
            else if (Input.GetMouseButtonUp(1))
            {
                thirdCam.shouldAim.Value = false;
            }

            if (Input.GetMouseButton(0))
            {
                ikAimWeapon.shouldAim = true;
                CmdFire(bulletSpawn.position, shootRay.direction);
            }
            else
            {
                ikAimWeapon.shouldAim = false;
            }
        }
        else
        {
            //DEBUG
            if (Input.GetMouseButtonDown(0))
            {
                DebugHUD.Debugg("Not armed ");
            }
        }

        if (Input.GetKeyDown(KeyCode.Space))
        {
            StartCoroutine(jump());
        }

        if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            arsenal.nextWeapon();
        }

        //TEST
        if (Input.GetKeyDown(KeyCode.H))
        {
            BeDead();
        }
        if (Input.GetKeyDown(KeyCode.M))
        {
            CmdToggleTestMute();
        }

        inputXZ = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"));
        animState.updateAnimator(new StateInput()
        {
            xz = inputXZ
        });
    }