Пример #1
0
    private void Start()
    {
        if (randomCharisma == true)
        {
            //Debug.Log("Random charisma");
            spawnEntitiesScript = FindObjectOfType <SpawnEntitiesAtRandom>();
            if (spawnEntitiesScript != null)
            {
                startingCharisma = Random.Range(spawnEntitiesScript.takerMinChar, spawnEntitiesScript.takerMaxChar);
            }
            else
            {
                startingCharisma = Random.Range(minStartingCharisma, maxStartingCharisma);
            }
            GetComponent <SphereOfInfluence>().currentCharisma = startingCharisma;
        }
        else
        {
            Debug.Log("Inherited charisma");
        }

        rigidbody        = GetComponent <Rigidbody>();
        startingPosition = transform.position;
        roamingPosition  = GetRoamingPosition();

        hitPointsManager   = GetComponent <HitPointsManager>();
        playParticleEffect = GetComponent <PlayParticleEffect>();
    }
Пример #2
0
        private IEnumerator Start()
        {
            // wait one frame because some explosions instantiate debris which should then
            // be pushed by physics force
            yield return(null);

            float multiplier = GetComponent <ParticleSystemMultiplier>().multiplier;

            float r           = 10 * multiplier;
            var   cols        = Physics.OverlapSphere(transform.position, r);
            var   rigidbodies = new List <Rigidbody>();

            foreach (var col in cols)
            {
                if (col.attachedRigidbody != null && !rigidbodies.Contains(col.attachedRigidbody) && IsControlledByMe(col.gameObject))
                {
                    rigidbodies.Add(col.attachedRigidbody);
                }
            }
            foreach (var rb in rigidbodies)
            {
                rb.AddExplosionForce(explosionForce * multiplier, transform.position, r, 1 * multiplier, ForceMode.Impulse);
                if (PhotonNetwork.isMasterClient)
                {
                    HitPointsManager hitpoints = rb.gameObject.GetComponent <HitPointsManager>();
                    if (hitpoints != null)
                    {
                        float distance = Vector3.Distance(rb.transform.position, transform.position);
                        hitpoints.TakeDamage((int)(explosionForce * 3f / distance));
                    }
                }
            }
        }
Пример #3
0
    /*
     * private void OnCollisionEnter(Collision collision)
     * {
     *  // On collision, inflict damage on the enemy target, only if colliding with the enemy target.
     *  if (currentState == State.Attack && enemyTarget != null && collision.gameObject.name == enemyTarget.name)
     *  {
     *      if (enemyTarget.tag != "Follower")
     *      {
     *          // Damage the target on collision. Damage = Base damage + killCount.
     *          Attack(collision.gameObject.GetComponent<HitPointsManager>(), attackDamage + killCount);
     *          attackCurrentTime = attackTimer;
     *          Debug.Log(this.name + " attacks " + enemyTarget + ", " + enemyTarget.name);
     *      }
     *  }
     * }
     */

    public void Attack(HitPointsManager enemy, int damage)
    {
        //attackSound.PlayRandomClip();
        enemy.RegisterHit(damage);
        //Debug.Log(name + " attacks " + enemy.gameObject.name);

        // After destroying the target, gain charisma. Follower and leader gain Violence.
        if (enemyTarget.GetComponent <HitPointsManager>().currentHitPoints <= 0)
        {
            ResolveKill();
        }
    }
Пример #4
0
    public static void Spawn(GameManager gameManager, PlayerMovementManager player, Vector3 position)
    {
        if (player.isDead)
        {
            gameManager.normalCamera.enabled   = true;
            gameManager.overheadCamera.enabled = false;
            Cursor.visible   = false;
            Cursor.lockState = CursorLockMode.Locked;

            player.photonView.RPC("SetPosAndRotation", PhotonTargets.All, position + new Vector3(0, 5, 0), Quaternion.identity);

            HitPointsManager hitpointsManager = player.GetComponent <HitPointsManager>();
            hitpointsManager.TellServerHealth(hitpointsManager.maxHealth);
        }
    }
    void Start()
    {
        gameSettings = FindObjectOfType <GameManager>();
        isIdle       = true;
        isWalking    = false;
        //animator = GetComponentInChildren<Animator>();

        /*
         * forward = Camera.main.transform.forward;
         * forward.y = 0;
         * forward = Vector3.Normalize(forward);
         * right = Quaternion.Euler(new Vector3(0, 90, 0)) * forward;
         */

        currentCharisma = startingCharisma;

        hitPointsManager   = GetComponent <HitPointsManager>();
        playParticleEffect = GetComponent <PlayParticleEffect>();
    }
Пример #6
0
 public void Attack(HitPointsManager enemy, int damage)
 {
     //attackSound.PlayRandomClip();
     enemy.RegisterHit(damage);
     //Debug.Log(name + " attacks " + enemy.gameObject.name);
 }