Example #1
0
    void Start()
    {
        _transform = transform;
        //Build up the slime class with Name
        slimeClass = new SlimeClass(slimeName);
        photonView = GetComponent <PhotonView>();
        gm         = GameManager.Instance;
        //Join team list
        JoinTeamList();
        //PathFinding config
        move = GetComponent <SlimeMovement>();
        if (move != null)
        {
            move.SetUpNavMeshAgent(slimeClass);
        }
        //Slime Health Display config
        SlimeHealth health = GetComponent <SlimeHealth>();

        if (health != null)
        {
            health.SetUpSlimeHealth(slimeClass);
        }

        if (!photonView.isMine && !slimeClass.canSpawnInBattle)
        {
            DisplaySlime(false, true);
        }
        else if (slimeClass.canSpawnInBattle)
        {
            Invoke("SlimeComponentEnable", 0.3f);
        }
    }
Example #2
0
 public override void Initialize()
 {
     slimeMovement = GetComponent <SlimeMovement>();
     combat        = GetComponent <Combat>();
     health        = GetComponent <HealthSystem>();
     enemyhealth   = target.GetComponent <HealthSystem>();
 }
Example #3
0
 void Start()
 {
     //Debug.Log(FrogMovement.lives);
     parent     = gameObject.GetComponentInParent <SlimeMovement>();
     max        = parent.lives;
     localScale = transform.localScale;
 }
 void Start()
 {
     currentHP    = MAX_HP;
     rangedAttack = GetComponent <EnemyRangedAttack>();
     rb           = GetComponent <Rigidbody2D>();
     player       = GameObject.FindGameObjectWithTag("Player");
     slimeMove    = GetComponent <SlimeMovement>();
     enemyMove    = GetComponent <EnemyMovement>();
 }
Example #5
0
 void Start()
 {
     photonView  = GetComponent <PhotonView>();
     slime       = GetComponent <Slime>().GetSlimeClass();
     agent       = GetComponent <Slime>().GetAgent();
     movement    = GetComponent <SlimeMovement>();
     health      = GetComponent <SlimeHealth>();
     gameManager = GameManager.Instance;
 }
Example #6
0
    // Use this for initialization
    void Start()
    {
        anim = GetComponent <Animation>();
        anim["Attack"].layer = 1;

        player        = GameObject.FindGameObjectWithTag("Player").transform;
        playerHealth  = player.GetComponent <PlayerHealth>();
        slimeMovement = GetComponent <SlimeMovement> ();
        slimeScaling  = GameObject.FindGameObjectWithTag("Environment").GetComponent <SlimeScaling> ();
    }
Example #7
0
 // Use this for initialization
 void Start()
 {
     //     HeathPoints = 1f;
     slimeCollider = gameObject.GetComponent <SphereCollider>();
     IsShielded    = false;
     firstColor    = true;
     slimeAction   = gameObject.GetComponent <SlimeActions>();
     isInvincible  = true;
     StartCoroutine(InvincibleFrames());
     slimeMovement = gameObject.GetComponent <SlimeMovement>();
     playerC       = GameObject.FindGameObjectWithTag(slimeMovement.parent).GetComponent <PlayerController>();
 }
Example #8
0
    void Awake()
    {
        game = Game.GetGame();

        slimeAudio           = GetComponent <AudioSource>();
        slimeMovement        = GetComponent <SlimeMovement>();
        enemyAttacking       = GetComponent <EnemyAttacking>();
        anim                 = GetComponent <Animation>();
        anim["Damage"].layer = 1;
        colliders            = GetComponents <Collider>();

        currentHealth = startingHealth; // set it to a more reasonable value
    }
Example #9
0
    private void SlowDownEffect()
    {
        List <Transform> enemyTeam = gameManager.GetEnemies2(target.root.tag)
                                     .Where(x => DistanceCalculate(target.position, x.position) <= effectAreaRadius * effectAreaRadius).ToList();

        for (int i = 0; i < enemyTeam.Count; i++)
        {
            Transform     e    = enemyTeam[i].root;
            SlimeMovement move = e.GetComponent <SlimeMovement>();
            if (move != null)
            {
                move.ChangeTheMovementSpeed(slowDownPrecentage);
            }
            e.GetComponent <SlimeHealth>().TakeDamage(attackDamage);
        }
    }
Example #10
0
    /// <summary>
    /// Stun enemies using a ray from the flashlight.
    /// </summary>
    /// <param name="ray"></param>
    private void FlashlightAttack(Ray ray)
    {
        RaycastHit shootHit;
        float      range         = 200;
        int        shootableMask = LayerMask.GetMask("Attackable");

        Debug.DrawRay(ray.origin, ray.direction, Color.red);
        if (Physics.Raycast(ray, out shootHit, range, shootableMask))
        {
            SlimeMovement enemyMovement = shootHit.collider.GetComponent <SlimeMovement>();
            if (enemyMovement != null)
            {
                enemyMovement.Stun();
            }
        }
    }
Example #11
0
 // Use this for initialization
 void Start()
 {
     slimeMovement = gameObject.GetComponent <SlimeMovement>();
     slimeHealth   = gameObject.GetComponent <SlimeHealth>();
 }
Example #12
0
    // Update is called once per frame
    void Update()
    {
        bool forward, back, left, right;

        forward = Input.GetKey(KeyCode.W);
        back    = Input.GetKey(KeyCode.S);
        left    = Input.GetKey(KeyCode.A);
        right   = Input.GetKey(KeyCode.D);

        Vector3 camRight   = Vector3.Cross(new Vector3(0, 1, 0), curentCamera.transform.forward).normalized;
        Vector3 camForward = -Vector3.Cross(new Vector3(0, 1, 0), camRight).normalized;

        Vector2 localClick = new Vector2();
        Camera  cam        = GameDirector.Director.currentCamera.GetComponent <Camera>();

        if (RectTransformUtility.RectangleContainsScreenPoint(Q, Input.mousePosition) && Input.GetMouseButtonDown(0))
        {
            Debug.Log("Q skill");
            foreach (GameObject enemy in GameDirector.Director.enemiesSpawned)
            {
                enemy.GetComponent <SlimeMovement>().stun(this.gameObject);
                LightningSegment.spawnLightningChain(this.gameObject, enemy, lightningLine);
                //Debug.Break();
            }
        }
        else if (RectTransformUtility.RectangleContainsScreenPoint(W, Input.mousePosition) && Input.GetMouseButtonDown(0))
        {
            Debug.Log("W skill");
        }
        else if (RectTransformUtility.RectangleContainsScreenPoint(E, Input.mousePosition) && Input.GetMouseButtonDown(0))
        {
            Debug.Log("E skill");
        }
        else if (RectTransformUtility.RectangleContainsScreenPoint(R, Input.mousePosition) && Input.GetMouseButtonDown(0))
        {
            Debug.Log("R skill");
            Instantiate(spookPrefab, this.transform);
            GameDirector.Director.mainLight.GetComponent <Light>().intensity = 0;
            Invoke("lightBackOn", 10);
        }
        else
        {
            RaycastHit retVal = new RaycastHit();
            Physics.Raycast(curentCamera.GetComponent <Camera>().ScreenPointToRay(Input.mousePosition), out retVal);
            Vector3       wantDir      = new Vector3();
            SlimeMovement attackTarget = null;

            if (retVal.collider != null)
            {
                SlimeMovement enemyHit = retVal.transform.gameObject.GetComponent <SlimeMovement>();
                if (enemyHit != null)
                {
                    wantDir = enemyHit.transform.position - this.transform.position;
                    if ((enemyHit.transform.position - this.transform.position).magnitude < attackRange && Input.GetMouseButtonDown(0))
                    {
                        attackTarget = enemyHit;
                    }
                }
                else
                {
                    wantDir = retVal.point + new Vector3(0, this.transform.position.y, 0) - this.transform.position;
                }
                wantDir = wantDir.normalized * moveSpeed;

                /*if (wantDir.magnitude > moveSpeed)
                 * {
                 *  wantDir = wantDir.normalized * moveSpeed;
                 * }
                 * else if (wantDir.magnitude < moveSpeed / 2)
                 * {
                 *  wantDir = wantDir.normalized * moveSpeed/2;
                 * }*/
                Debug.DrawRay(this.transform.position, wantDir, Color.cyan);
                if (Time.time - moveTime > 0 && Input.GetMouseButtonDown(0))
                {
                    float jump = Random.value > .7 ? moveSpeed : 0;
                    phys.velocity = new Vector3(wantDir.x, phys.velocity.y + jump, wantDir.z);
                    moveTime      = Time.time + moveDownTime;
                    //Debug.Log("moved!");
                }
            }

            if (attackTarget && Time.time - nextAttackTime > 0)
            {
                energy        += attack(attackTarget);
                nextAttackTime = Time.time + attackCoolDown;
            }
        }


        /*Vector3 newMove = new Vector3();
         * newMove.y = phys.velocity.y;
         * if (forward) newMove += moveSpeed*camForward;
         * if (back) newMove += -moveSpeed * camForward;
         * if (left) newMove += -moveSpeed * camRight;
         * if (right) newMove += moveSpeed * camRight;
         */

        //Debug.DrawRay(this.transform.position, camRight, Color.green);
        //Debug.DrawRay(this.transform.position, camForward, Color.red);



        //phys.velocity = newMove;
    }
Example #13
0
 private float attack(SlimeMovement enemy)
 {
     LightningSegment.spawnLightningChain(this.gameObject, enemy.gameObject, lightningLine);
     enemy.damage(1);
     return(1);
 }