Exemple #1
0
    void OnTriggerStay(Collider collider)
    {
        BodyVirtualController virtualController =
            collider.GetComponent <BodyVirtualController> ();

        if (collider.isTrigger || virtualController == null)
        {
            return;
        }

        IHealthController enemyHealthController = collider.GetComponent <IHealthController> ();
        float             distanceX             = Mathf.Abs(rigidBody.position.x - collider.transform.position.x);
        float             distanceZ             = Mathf.Abs(rigidBody.position.z - collider.transform.position.z);
        float             distanceY             = Mathf.Abs(rigidBody.position.y - collider.transform.position.y);

        float xzDistanceMax = 0.1f;
        float yDistanceMax  = 0.1f;
        bool  validDistance = distanceX < xzDistanceMax &&
                              distanceZ < xzDistanceMax &&
                              distanceY < yDistanceMax;

        if (enemyHealthController != null)
        {
            combatController.LightMeleeAttack(enemyHealthController);
        }

        if (timeSlowing || timePausing || timeStopping)
        {
            //timeManipulatorController.AddTimeManipulatableObject ( virtualController );
        }
    }
 private void Awake()
 {
     anim = GetComponent <Animation>();
     anim.Stop();
     healthController              = GetComponent <IHealthController>();
     healthController.HandleDeath += Die;
 }
 private void Awake()
 {
     state               = GameState.Paused;
     healthController    = FindObjectOfType <BaseHealthController>();
     baseDeathController = FindObjectOfType <BaseDeathController>();
     enemyManager        = FindObjectOfType <EnemyManager>();
     uiManager           = FindObjectOfType <UIManager>();
     uiMenue             = FindObjectOfType <UIMenue>();
 }
Exemple #4
0
    public void CollidedWith(Collider collider)
    {
        Debug.Log("Player collided with " + collider.gameObject.name);
        Hurtbox           hurtbox           = collider.GetComponent <Hurtbox>();
        IHealthController hurtBoxController = hurtbox.GetComponentInParent <IHealthController>(); // the parent gameobject will implement the health and damage
        Damage            attackDamage      = new Damage(15);

        hurtBoxController?.ReceiveDamage(attackDamage);
    }
Exemple #5
0
    public GameplayController(ILevelSetter levelSetter, IEnemyController enemyController, IHealthController healthController, IGoldController goldController, ITowerController towerController, IObjectPooler objectPooler)
    {
        _levelSetter      = levelSetter;
        _enemyController  = enemyController;
        _healthController = healthController;
        _goldController   = goldController;
        _towerController  = towerController;
        _objectPooler     = objectPooler;

        _healthController.HealthIsZero += EndGame;
    }
    void Start()
    {
        Camera camera = Camera.main;

        if (camera == null)
        {
            GameObject cameraGameObject = Instantiate(new GameObject());
            camera = cameraGameObject.AddComponent <Camera> ();
        }

        cameraController = camera.GetComponent <ICameraController> ();
        if (cameraController == null)
        {
            cameraController = camera.gameObject.AddComponent <DynamicCameraController> ();
        }

        specialBox = GameObject.FindGameObjectWithTag("Special Box");
        if (specialBox == null)
        {
            specialBox = new GameObject();
        }

        GameObject player = GameObject.FindGameObjectWithTag("Player");

        playerInputController = player.GetComponent <IInputController> ();
        if (player == null || playerInputController == null)
        {
            playerInputController = new NullInputController();
        }
        playerInputController.SetCameraController(cameraController);
        playerInputController.SetCameraMode(
            CameraMode.THIRD_PERSON,
            Vector3.zero
            );

        playerVirtualController = player.GetComponent <IVirtualController> ();
        if (player == null || playerVirtualController == null)
        {
            playerVirtualController = new NullVirtualController();
        }

        playerHealthController = player.GetComponent <IHealthController> ();
        if (playerHealthController == null)
        {
            playerHealthController = new NullHealthController();
        }

        CameraModeTrigger [] cameraModeTriggers = ( CameraModeTrigger [] )GameObject.FindObjectsOfType <CameraModeTrigger> ();
        foreach (CameraModeTrigger cameraModeTrigger in cameraModeTriggers)
        {
            cameraModeTrigger.SetCameraModeListener(this);
        }
    }
Exemple #7
0
 private void OnTriggerEnter(Collider other)
 {
     if (!other.isTrigger)
     {
         IHealthController target = other.gameObject.GetInterface <IHealthController>();
         if (target != null)
         {
             target.Damage(damage);
             hitBox.enabled = false;
         }
     }
 }
Exemple #8
0
    public virtual void HeavyAttack(IHealthController healthController)
    {
        if (healthController == null)
        {
            return;
        }

        if (!IsAttacking())
        {
            heavyAttackWindowTimer.startTimer();
            healthController.DecreaseHP(heavyAttackDamage);
        }
    }
    void OnCollisionEnter(Collision collision)
    {
        if (!indestructableTimer.stopped())
        {
            return;
        }

        IHealthController healthController = collision.gameObject.GetComponent <IHealthController> ();

        if (healthController != null)
        {
            combatController.LightMeleeAttack(healthController);
        }
    }
    public virtual void FireProjectile(IHealthController healthController)
    {
        Debug.Log("Enter FireProjectile ()");

        if (!IsFiringProjectile())
        {
            Debug.Log("firing");
            fireCoolDownTimer.startTimer();
            GameObject projectile = ( GameObject )Instantiate(Resources.Load(GetProjectilePrefabName()));
            if (projectile != null)
            {
                Debug.Log("Instantiated");
                projectile.transform.position = transform.position;
                projectile.transform.up       = transform.forward;
            }
        }
    }
Exemple #11
0
    private void OnCollisionEnter(Collision collision)
    {
        Boat waterObject = collision.gameObject.GetComponentInParent <Boat>();

        if (waterObject != null /* && firedBy != waterobject*/)
        {
            waterObject.Velocity.v += (shotPosition - collision.transform.position).normalized * cannonBallForce / 10;
            waterObject.Mass       += 100;
            Destroy(this);
        }
        else
        {
            IHealthController h = collision.gameObject.GetInterface <IHealthController>();
            if (h != null)
            {
                h.Damage(15);
                Destroy(this);
            }
        }
    }
Exemple #12
0
 public void LightMeleeAttack(IHealthController target)
 {
     // do nothing
 }
Exemple #13
0
 // Start is called before the first frame update
 protected virtual void Start()
 {
     healthController = GetComponent <IHealthController>();
     healthUIController.SetMaxValue(maxHealth);
 }
Exemple #14
0
 public void FireProjectile(IHealthController target)
 {
     // do nothing
 }
Exemple #15
0
 public virtual void FireProjectile(IHealthController healthController)
 {
     // do nothing
 }
Exemple #16
0
 public void LightMeleeAttack(IHealthController target)
 {
     meleeAttackController.LightAttack(target);
 }
Exemple #17
0
 public void HeavyMeleeAttack(IHealthController target)
 {
     meleeAttackController.HeavyAttack(target);
 }
Exemple #18
0
 public void FireProjectile(IHealthController target)
 {
     projectileAttackController.FireProjectile(target);
 }
Exemple #19
0
 private void Awake()
 {
     healthController = GetComponentInParent <IHealthController>();
 }
Exemple #20
0
 private void Awake()
 {
     enemyHealthController              = GetComponent <IHealthController>();
     enemyHealthController.HandleDeath += Die;
     route = FindObjectOfType <LevelManager>().Level.Route;
 }
Exemple #21
0
 public void SetCallbacks(IHealthController healthController)
 {
     healthController.HealthChanged += SetHealth;
 }
Exemple #22
0
    void Start()
    {
        bodyMass    = GetBodyMass();
        drag        = GetDrag();
        angularDrag = GetAngularDrag();
        normalSpeed = GetNormalSpeed();

        runSpeedMax       = GetRunSpeedMax();
        runSpeedIncrement = GetRunSpeedIncrement();
        turnSpeed         = GetTurnSpeed();

        maxHP = GetMaxHP();

        rigidBody = GetComponent <Rigidbody> ();
        if (rigidBody == null)
        {
            rigidBody = gameObject.AddComponent <Rigidbody> ();
        }
        rigidBody.mass           = bodyMass;
        rigidBody.drag           = drag;
        rigidBody.angularDrag    = angularDrag;
        rigidBody.freezeRotation = true;
        rigidBody.isKinematic    = false;

        healthController = GetComponent <IHealthController> ();
        if (healthController == null)
        {
            healthController = new NullHealthController();
        }

        jumpController = GetComponent <IJumpController> ();
        if (jumpController == null)
        {
            jumpController = new NullJumpAttributes();
        }

        interactionController = GetComponent <IInteractionController> ();
        if (interactionController == null)
        {
            interactionController = new NullInteractionController();
        }

        timeManipulatableController = GetComponent <ITimeManipulatableController> ();
        if (timeManipulatableController == null)
        {
            timeManipulatableController = new NullTimeManipulatableController();
        }

        combatController = GetComponent <ICombatController> ();
        if (combatController == null)
        {
            combatController = new NullCombatController();
        }

        timePauseProjectileAttackController = GetComponent <TimePauseProjectileAttackController> ();
        if (timePauseProjectileAttackController == null)
        {
            timePauseProjectileAttackController = new NullProjectileAttackController();
        }

        timeSlowProjectileAttackController = GetComponent <TimeSlowProjectileAttackController> ();
        if (timeSlowProjectileAttackController == null)
        {
            timeSlowProjectileAttackController = new NullProjectileAttackController();
        }
    }
Exemple #23
0
 public virtual void LightAttack(IHealthController healthController)
 {
     // do nothing
 }