Ejemplo n.º 1
0
    void OnTriggerEnter(Collider other)
    {
        if (other.name.Contains("Sword"))
        {
            if (transform.name.Substring(0, 5).Equals(other.transform.root.name.Substring(0, 5)))
            {
                return;
            }
            currentHP -= selectAttack;
            float currentHealthPercent = (float)currentHP / (float)minionHP;
            OnHealthPercentChanged(currentHealthPercent);
        }

        else if (other.name.Contains("Projectile"))
        {
            if (transform.name.Substring(0, 5).Equals(other.transform.root.name.Substring(0, 5)))
            {
                return;
            }

            currentHP -= selectAttack;
            float currentHealthPercent = (float)currentHP / (float)minionHP;
            OnHealthPercentChanged(currentHealthPercent);
        }

        if (currentHP <= 0)
        {
            Debug.Log("minion die");
            agent.isStopped = true;
            minionState     = MinionState.die;
        }
    }
Ejemplo n.º 2
0
    public bool Die() //actually transforming
    {
        //if not picked up, it cannot transform
        if (currMinionState != MinionState.PickedUp)
        {
            return(false);
        }
        Debug.LogWarning("transformed");

        //remove from player
        PlayerScript.Instance.pickedUpObj = null;

        Destroy(spawnPointGO);

        //UpdateClearState();
        UpdateObject();
        GetComponent <SpriteRenderer>().sprite = objSpr;
        GetComponent <Animator>().enabled      = false;

        currMinionState  = MinionState.Dead;
        trigger.enabled  = false;
        bodyColl.enabled = false;

        //set to transformed
        transformed = true;

        StartCoroutine(FadeSprite());

        return(true);
    }
Ejemplo n.º 3
0
    void OnTriggerEnter2D(Collider2D col)
    {
        //3 types of triggers: turn left, turn right, go to nearest tower.
        //...

        Debug.Log("Collide");

        switch (col.tag)
        {
        case "TurnLeft":
            currRotation = (Vars.Rotation)((int)(currRotation) + 1);
            break;

        case "TurnRight":
            currRotation = (Vars.Rotation)((int)(currRotation) - 1);
            break;

        case "GotoTower":
            currState = MinionState.ToTower;
            break;

        case "Destroy":
            currState = MinionState.Dead;
            break;
        }
    }
Ejemplo n.º 4
0
    private void Attack()
    {
        m_Anim.ResetTrigger("Move");
        m_Anim.SetTrigger("Attack");       // 공격 애니메이션 트리거 던져줌
        m_nvAgent.velocity = Vector3.zero; //미니언 이동 멈춰주고

        if (isAttackComplete)
        {
            InvokeRepeating("SearchTarget", 0f, 1.0f);                   //공격도중에는 새로운적을 찾고
        }
        else
        {
            CancelInvoke("SearchTarget");
        }

        if (attackTarget != null)
        {
            transform.LookAt(attackTarget.transform.position);                                                             //공격대상을 항상 바라보게

            if ((Vector3.Distance(transform.position, attackTarget.transform.position)) > attackRange && isAttackComplete) // 공격하다가 공격대상이 미니언 사거리보다 멀어지면
            {
                attackTarget = null;
                minionState  = MinionState.Rush;
                return;
            }
        }
        else
        {
            minionState = MinionState.Rush;
        }
    }
Ejemplo n.º 5
0
    public bool ApplyDamage(int damage = 0)
    {
        CurrentHP -= damage;

        if (CurrentHP <= 0 && state != MinionState.dead)
        {
            state = MinionState.dead;
            switch (team)
            {
            case Teams.red:
                GlobalRefs.Spawner.blueTeamCount--;
                break;

            case Teams.blue:
                GlobalRefs.Spawner.redTeamCount--;
                break;

            default:
                break;
            }
            StartCoroutine(DeathAnimation());
            return(true);
        }
        return(false);
    }
Ejemplo n.º 6
0
        public void OnReadyStart()
        {
            if (enabled == false)
            {
                return;
            }

            CancelAttackIfIsAttacking();

            focusTarget             = null;
            nav.enabled             = false;
            navMeshObstacle.enabled = false;
            minionState             = MinionState.Idle;
            gameObject.SetActive(true);
            transform.position = readyEndPosition;
            //多人連線P2轉向180度
            if (isMultipleGame)
            {
                if (!PhotonNetwork.IsMasterClient)
                {
                    transform.rotation = Quaternion.AngleAxis(180, Vector3.up);
                }
                else
                {
                    transform.rotation = Quaternion.identity;
                }
            }
            else
            {
                transform.rotation = Quaternion.identity;
            }
            minionAnimator.enabled = true;
            MinionAC(MinionState.Idle, isMultipleGame);
        }
Ejemplo n.º 7
0
    void UpdatePickedUp()
    {
        if (PlayerScript.Instance.pickedUpObj != null)
        {
            UIManager.Instance.StartPopUp("My hands are full. I can't pick it up.", "Georgia Daisy");
        }
        else
        {
            //start countdown
            currentPickUpTime = 0;

            firstWarningSent  = false;
            secondWarningSent = false;

            currMinionState = MinionState.PickedUp;

            //add to playerscript
            PlayerScript.Instance.pickedUpObj = this;

            //make sprite transparent
            GetComponent <SpriteRenderer>().color = new Color(1, 1, 1, 0);

            //deactivate collider
            bodyColl.enabled = false;

            //image
            UIManager.Instance.AddObjImage(objSpr, normalSprite);
        }
    }
Ejemplo n.º 8
0
 protected void CheckNearbyEnemies()
 {
     if (state == MinionState.walking || state == MinionState.approaching)
     {
         // Get all gameobjects within ApproachRadius distance
         Collider[] hitColliders = Physics.OverlapSphere(transform.position, ApproachRadius);
         float      minDist      = Mathf.Infinity;
         foreach (Collider hit in hitColliders)
         {
             // if you find a player, immediately shoot at him (high priority over minions)
             MainPlayer player = hit.GetComponent <MainPlayer>();
             if (player)
             {
                 if (state == MinionState.approaching && Vector3.Distance(player.transform.position, transform.position) <= AttackRadius)
                 {
                     goal        = player.transform;
                     agent.speed = 0;
                     state       = MinionState.attacking;
                 }
                 else
                 {
                     goal  = player.transform;
                     state = MinionState.approaching;
                 }
                 return;
             }
             // Check the closest minion out of all minions closeby
             Minion minion = hit.GetComponent <Minion>();
             if (minion && !minion.locked && minion.state == MinionState.walking && minion.team != team)
             {
                 minion.locked = true;
                 float curDist = Vector3.Distance(minion.transform.position, transform.position);
                 if (minion.state == MinionState.walking && curDist <= AttackRadius)
                 {
                     goal        = minion.transform;
                     agent.speed = 0;
                     state       = MinionState.attacking;
                     minion.AttackMe(this);
                     return;
                 }
                 else if (minion.state == MinionState.walking && curDist < minDist)
                 {
                     minDist = curDist;
                     goal    = minion.transform;
                     minion.ApproachMe(this);
                     state = MinionState.approaching;
                 }
                 minion.locked = false;
             }
         }
         if (minDist != Mathf.Infinity)
         {
             return;
         }
         else
         {
             FollowNexus();
         }
     }
 }
Ejemplo n.º 9
0
    void Update()
    {
        if (state.charstate == CharacterStates.CharState.Death)
        {
            StartCoroutine(PlayerDeath());
            return;
        }


        Collider[] collider = Physics.OverlapSphere(player.position, detectRange, mask);

        foreach (Collider target in collider)
        {
            if (target.tag == "Enemy")
            {
                enemy     = target.GetComponent <Transform>();
                miniState = target.GetComponent <MinionState>();
            }
        }

        if (!IsAttack())
        {
            OnSkill1();
            OnSkill2();
            OnSkill3();
            OnAtk();
        }

        Move();
    }
Ejemplo n.º 10
0
    // Attempt to change state
    public void changeState(MinionStateMachine.MinionState new_state)
    {
        if (new_state == currState_)
        {
            return;
        }

        // can we make this state change?
        if (!checkStateChange(currState_, new_state))
        {
            return;
        }

        Debug.Log("MinonStateMachine.changeState: Current State = " + stateToString(currState_) +
                  ", New State = " + stateToString(new_state));

        Debug.Log("MinonStateMachine.changeState: state change OK");

        // set the new state
        currState_ = new_state;

        // send the event
        if (MinionStateChangeEvent != null)
        {
            MinionStateChangeEvent(new_state);
        }
    }
Ejemplo n.º 11
0
 public void MinionAC(MinionState state, bool isMultiple)
 {
     if (isMultiple)
     {
         GetComponent <PhotonView>().RPC("MinionAC", RpcTarget.All, state, false);
         return;
     }
     if (state == MinionState.Idle)
     {
         minionAnimator.SetBool(animation_Run, false);
         minionAnimator.SetBool(animation_Grab, false);
         minionAnimator.SetTrigger(animation_Idle);
     }
     else if (state == MinionState.Walk)
     {
         minionAnimator.SetBool(animation_Run, true);
     }
     else if (state == MinionState.Grab)
     {
         minionAnimator.SetBool(animation_Grab, true);
     }
     else
     {
         minionAnimator.SetBool(animation_Run, false);
         minionAnimator.SetTrigger(animation_Attack);
     }
 }
Ejemplo n.º 12
0
    void Update()
    {
        if (currentState == MinionState.FOLLOW)
        {
            navMeshAgent.destination = playerFollowTarget.transform.position;
        }

        if (currentState == MinionState.PICKUP)
        {
            navMeshAgent.destination = pickupList[0].transform.position;
            if (Vector3.Distance(transform.position, navMeshAgent.destination) <= 1.5f) //Tested the touching distance in the editor
            {
                pickupList[0].Pickup(pickupTarget);
                currentState = MinionState.DROPOFF;
            }
        }

        if (currentState == MinionState.DROPOFF)
        {
            navMeshAgent.destination = jailTarget.transform.position;
            if (Vector2.Distance(new Vector2(transform.position.x, transform.position.z), new Vector2(jailTarget.transform.position.x, jailTarget.transform.position.z)) <= navMeshAgent.speed * Time.deltaTime)
            {
                pickupList[0].DropOff();
            }
        }
    }
Ejemplo n.º 13
0
    void UpdateAttacking()
    {
        currMinionState = MinionState.Attacking;

        switch (currAttackState)
        {
        case AttackState.None:
            currAttackState       = AttackState.Anticipation;
            anticipationStartTime = 0;     //set to zero
            break;

        case AttackState.Anticipation:
            Attack();
            break;

        case AttackState.Release:
            //go back to None
            currAttackState = AttackState.None;

            if (destinationSetter.target.CompareTag("Player"))
            {
                UpdateFollowing(destinationSetter.target.gameObject);
            }
            else
            {
                UpdateReturning();
            }

            break;
        }
    }
Ejemplo n.º 14
0
    private void Rush()
    {
        m_Anim.ResetTrigger("Attack");
        m_Anim.SetTrigger("Move"); //이동애니메이션 트리거 던져줌
        if (attackTarget == null)  // 돌진하는도중 공격타겟이 없으면
        {
            InvokeRepeating("SearchTarget", 0f, 0.5f);
            m_nvAgent.SetDestination(currDestination.transform.position);
        }
        else // 돌진하는도중 공격타겟이 나타나면
        {
            CancelInvoke("SearchTarget"); // 새로운 공격타겟을 찾는함수를 잠시 꺼주고
            m_nvAgent.SetDestination(attackTarget.transform.position);                               // 도착지점을 공격타겟으로 변경

            if (Vector3.Distance(transform.position, attackTarget.transform.position) < attackRange) // 쫓다가 공격타겟이 미니언 공격사거리 내에 들어오면
            {
                minionState = MinionState.Attack;
            }

            if (Vector3.Distance(transform.position, attackTarget.transform.position) > searchRange) // 쫓다가 공격타겟이 탐색범위를 넘어가면
            {
                InvokeRepeating("SearchTarget", 0f, 0.5f);                                           //탐색함수 다시실행
                attackTarget = null;
            }
        }
    }
Ejemplo n.º 15
0
    public void resourceCollecting()
    {
        if (assignedBuilding.GetComponent <ResourceExtractor>().extractedResourceType == ResourceBase.ResourceType.Free)
        {
            return;
        }
        // Debug.Log("rc");
        switch (minionState)
        {
        case MinionState.Out:
            if (targetresource != null)
            {
                WalkTowardDestination(targetresource);
            }

            if (Vector3.Distance(transform.position, normalPos) < 1f || targetresource == null)
            {
                minionState         = MinionState.Working;
                extractionBeginTime = Time.time;
            }
            break;

        case MinionState.Working:

            if (extractionBeginTime + extractionDuration <= Time.time)
            {
                minionState = MinionState.In;
                targetInstanceController.removeIfEmpty();
            }

            break;

        case MinionState.In:
            WalkTowardDestination(assignedBuilding);

            if (Vector3.Distance(transform.position, normalPos) < 1f)
            {
                minionState = MinionState.NotAssigned;
                ResourceExtractor re        = assignedBuilding.GetComponent <ResourceExtractor>();
                GameObject        newtarget = re.findNearbyResource();
                re.addResourceToContainer(pack);
                pack = 0;
                if (newtarget != null)
                {
                    setTargetResource(newtarget);

                    minionState = MinionState.Out;
                }
                else
                {
                    minionState = MinionState.NotAssigned;
                }
            }
            break;

        default:
            break;
        }
    }
Ejemplo n.º 16
0
    //private MinionUI minBar;

    //public MainUiBar mainUI;

    void Start()
    {
        anim   = GetComponent <MinionAnimator>();
        status = GetComponent <MinionState>();

        //minBar = GameObject.FindGameObjectWithTag("MinUI").GetComponent<MinionUI>();
        //mainUI = GameObject.Find("UI").GetComponent<MainUiBar>();
    }
Ejemplo n.º 17
0
    void UpdateFollowing(GameObject target_go)
    {
        //target = target_go;
        destinationSetter.target = target_go.transform;

        currMinionState = MinionState.Following;
        currAttackState = AttackState.None;
    }
Ejemplo n.º 18
0
 private void Awake()
 {
     _model       = GetComponent <Model>();
     _minionState = GetComponent <MinionState>();
     _agentTheta  = GetComponent <AgentTheta>();
     _flock       = GetComponent <FlockEntity>();
     _model       = GetComponent <Model>();
 }
Ejemplo n.º 19
0
    void UpdateReturning()
    {
        currMinionState = MinionState.Returning;
        currAttackState = AttackState.None;

        //move to spawnPoint
        destinationSetter.target = spawnPointGO.transform;
    }
Ejemplo n.º 20
0
 public void setTargetResource(GameObject target)
 {
     targetresource = target;
     minionState    = MinionState.Out;
     Debug.Log(target.name);
     targetInstanceController = targetresource.GetComponent <ResourceInstanceController>();
     extractionDuration       = targetInstanceController.duration;
     pack += targetInstanceController.removeCapacity(amount);
 }
Ejemplo n.º 21
0
 public FollowState(MoveRun mR, Model model, MinionState state, float criticalHealthAmount, int team, INode node)
 {
     _moveRun         += mR;
     _model            = model;
     _state            = state;
     _critHealthAmount = criticalHealthAmount;
     _team             = team;
     _node             = node;
 }
Ejemplo n.º 22
0
 // ミニオンの状態変更メソッド
 public void SetState(MinionState tempState, Transform targetObj = null)
 {
     GetMinionState = tempState;
     if (tempState == MinionState.Walk)
     {
         elapseTime = 0f;
         meshAgent.SetDestination(new Vector3(target.position.x, target.position.y, target.position.z));
         meshAgent.isStopped = false;
     }
     else if (tempState == MinionState.Chase)
     {
         meshAgent.ResetPath();
         // 追いかける対象をセット
         unitTransform = targetObj;
         meshAgent.SetDestination(unitTransform.position);
         meshAgent.isStopped = false;
     }
     else if (tempState == MinionState.Wait)
     {
         Stop();
     }
     else if (tempState == MinionState.Attack)
     {
         SetAttack();
     }
     else if (tempState == MinionState.TowerAttack)
     {
         SetAttack();
     }
     else if (tempState == MinionState.Freeze)
     {
         Stop();
     }
     else if (tempState == MinionState.Damage)
     {
         minionAnimator.AnimeRest("Attack");
         minionAnimator.AnimeTrigger("Damage");
         meshAgent.isStopped = true;
         if (statusController.Get_HP <= 0)
         {
             SetState(MinionState.Dead);
         }
     }
     else if (tempState == MinionState.Dead)
     {
         GetMinionState = MinionState.Dead;
         PassExperience();
         meshAgent.ResetPath();
         minionAnimator.AnimeTrigger("Deth");
         // ミニオンの場合
         if (!characterCheck)
         {
             StartCoroutine("Deth");
         }
     }
 }
Ejemplo n.º 23
0
 private void isInRange(float distance, GameObject target)
 {
     // Si no esta a distancia de ataque se acerca a el
     if (distance > attackRange)
     {
         moveTowardsTarget(target);
     }
     else
     {
         state = MinionState.ATTACK;
     }
 }
Ejemplo n.º 24
0
    private void onPirateDonked(System.Object args)
    {
        PirateDonkedArgs pirateDonkedArgs = (PirateDonkedArgs)args;

        if (!pickupList.Contains(pirateDonkedArgs.DonkedPirate))
        {
            pickupList.Add(pirateDonkedArgs.DonkedPirate);
        }
        if (currentState == MinionState.FOLLOW)
        {
            currentState = MinionState.PICKUP;
        }
    }
Ejemplo n.º 25
0
        IEnumerator EnableNavMeshAgain(Vector3 des)
        {
            navMeshObstacle.enabled = false;
            yield return(null);

            if (!navMeshObstacle.enabled)
            {
                nav.enabled = true;
            }
            nav.SetDestination(des);
            minionState = MinionState.StopAction;
            MinionAC(MinionState.Walk, isMultipleGame);
        }
Ejemplo n.º 26
0
        public virtual void onDeath()
        {
            minionState = MinionState.DEAD;
            Messages.OutgoingMessages.Game.GMinionHealthInfo.sendMessage(game.players, this);

            if (killerPlayer != null)
            {
                // STATCODE
                PlayerStats pStats = killerPlayer.game.statTracker.getPlayerStatsOfPlayer(killerPlayer);
                pStats.minionsKilled += 1;

                killerPlayer.addCash(getKillGold(), true);
            }
        }
Ejemplo n.º 27
0
 void Start()
 {
     m_MinionType      = MinionType.E_CREEP1;
     direction         = BomberGuide.getRandomDir();
     canProceed        = true;
     originalCellsFree = cellsFree;
     movement          = new MovementData(3);
     physBody          = transform.GetComponent <Rigidbody2D>();
     bodyDestination   = transform.position;
     GetComponent <DefaultCharacter>().InitChar();
     character   = GetComponent <DefaultCharacter>();
     animator    = transform.GetChild(4).GetChild(0).GetComponent <Animator>();
     minionState = MinionState.E_NEUTRAL;
 }
Ejemplo n.º 28
0
    public void CustomAwake()
    {
        CurrentHP = MaxHP;
        agent     = GetComponent <NavMeshAgent>();
        IsOnNavMesh(agent);
        agent.destination = _goal.position;

        anim  = transform.parent.GetComponent <Animator>();
        state = MinionState.walking;
        rb    = GetComponent <Rigidbody>();
        InitialAnimatorSpeed = anim.speed;
        CenterGoal           = _goal;
        GetGoalNexus();
        DestroyParticles = GlobalRefs.Explosion;
    }
Ejemplo n.º 29
0
    public void OnTriggerEnter(Collider other)
    {
        GameObject  parent   = other.transform.root.gameObject;
        MinionState minState = parent.GetComponent <MinionState>();

        if (other.gameObject.tag == "EnemyAtk")
        {
            //if(PhotonNetwork.isMasterClient)
            //{
            //	photonView.RPC("Damage", PhotonTargets.AllViaServer);
            //}

            hp -= minState.Att;
        }
    }
Ejemplo n.º 30
0
    // Use this for initialization
    private void Start()
    {
        agent = GetComponent <UnityEngine.AI.NavMeshAgent>();

        agent.updateRotation = false;
        agent.updatePosition = true;

        // Old find target, using field of view list now
        //StartCoroutine(FindTarget());
        state = MinionState.wander;

        timer = wanderTimer;

        SetTeam(team);
    }
    void OnGUI()
    {
        if(_selected && networkView.isMine)
        {
            GUILayout.BeginArea(new Rect(Screen.width * 0.38f, Screen.height * 0.70f, Screen.width * 0.60f, Screen.height * 0.15f));
            GUILayout.BeginHorizontal();

            if(GUILayout.Button(IdleButtonTexture, GUILayout.Width(64), GUILayout.Height(64)))
            {
                State = MinionState.IDLE;
                _selected = true;
            }

            if(GUILayout.Button(FollowButtonTexture, GUILayout.Width(64), GUILayout.Height(64)))
            {
                State = MinionState.FOLLOW;
                _selected = false;
            }

            if(GUILayout.Button(AttackButtonTexture, GUILayout.Width(64), GUILayout.Height(64)))
            {
                State = MinionState.ATTACK;
                _selected = false;
            }

            if(GUILayout.Button(SearchButtonTexture, GUILayout.Width(64), GUILayout.Height(64)))
            {
                State = MinionState.SEARCH;
                _selected = false;
            }

            GUILayout.EndHorizontal();
            GUILayout.EndArea();
        }
    }
Ejemplo n.º 32
0
		public virtual void onDeath()
		{
			minionState = MinionState.DEAD;
            Runner.Graphics.minionDied(this);
		}
Ejemplo n.º 33
0
        public virtual void onDeath()
        {
            minionState = MinionState.DEAD;
            Messages.OutgoingMessages.Game.GMinionHealthInfo.sendMessage(game.players,this);

            if (killerPlayer != null)
            {
                // STATCODE
                PlayerStats pStats = killerPlayer.game.statTracker.getPlayerStatsOfPlayer(killerPlayer);
                pStats.minionsKilled += 1;

                killerPlayer.addCash(getKillGold(), true);
            }
        }