Beispiel #1
0
        /// <summary>
        /// Begins the Subject's death. Subjects can be 'down-but-not-out' for a period of time, then completely die.
        /// </summary>
        void Die()
        {
            // Deny controls, reset velocity, turn off ai, turn off collider
            if (_isControllable)
            {
                SetInputPermission(false, false, false);
            }

            _myRigidbody.velocity        = Vector3.zero;
            _myRigidbody.angularVelocity = 0f;

            if (GetComponent <Intellect>() != null)
            {
                GetComponent <Agent>().enabled = false;
            }

            GetComponent <Collider2D>().enabled = false;

            if (Stats.DeathFx)
            {
                StaticUtil.Spawn(Stats.DeathFx, transform.position, Quaternion.identity);
            }
            if (OnDeath != null)
            {
                OnDeath();
            }

            // Update stats
            Stats.Deaths++;
            LastAttacker.Stats.Kills++;
            StaticUtil.GiveXp((int)Stats.XpReward.Actual, LastAttacker);
            //

            IsDead = true;
            StartCoroutine(CrippleAndDie());
        }
Beispiel #2
0
        private void Start()
        {
            if (IsOwner)
            {
                SetInputPermission(true, true, true);
                OnHealthChanged  += Subject_OnHealthChanged;
                OnSwitchedWeapon += Subject_OnSwitchedWeapon;
                OnReload         += Subject_OnReload;
                OnFire           += Subject_OnFire;
            }
            isPlayer          = true;
            serializePosition = SerializeVector3Properties.XY;
            serializeRotation = SerializeVector3Properties.Z;
            serializeScale    = SerializeVector3Properties.None;
            StartCoroutine(InputLoop());

            if ((int)Stats.Level.Actual == 0)
            {
                StaticUtil.GiveXp((int)Stats.Experience.Max, this);
            }

            // TODO Cleanup
            // Different (terrible) formatting to save vertical space... Was getting pointlessly long.
            _currentWeapon = 0;
            bool weaponSetupIsOkay = true;

            if (Stats.WeaponMountPoint != null)
            {
                _hand = Stats.WeaponMountPoint.transform;
            }
            else
            {
                weaponSetupIsOkay = false;
                if (WeaponListEditor.Count != 0)
                {
                    Debug.LogWarning("No Weapon Mount Point is specified! Assign it on the Subject.");
                }
            }

            // Initialize if there were no problems.
            if (!weaponSetupIsOkay)
            {
                return;
            }
            if (LogDebug)
            {
                Debug.Log(".... Weapon setup is okay");
            }

            // Create the predefined weapons, if any
            if (WeaponListEditor.Count == 0)
            {
                return;
            }
            foreach (GameObject boomboom in WeaponListEditor)
            {
                PickupWeapon(boomboom);
            }
            StartCoroutine(ChangeWeaponToSlot(0));
            _initialized = true;
        }