private void Stun(bool player)
 {
     if (isRed == player)
     {
         aState = actionState.stunned;
     }
 }
 void SituationCheck()
 {
     Collider[] hitColliders = Physics.OverlapSphere(transform.position, checkRadius, checkFor);
     foreach (Collider col in hitColliders)
     {
         if (enemy == null)
         {
             enemy = col.transform;
         }
         else
         {
             if (Vector3.Distance(transform.position, enemy.position) > Vector3.Distance(transform.position, col.transform.position))
             {
                 enemy = col.transform;
             }
         }
     }
     if (enemy == null)
     {
         state = actionState.Exploring;
     }
     else
     {
         state = actionState.Fighting;
     }
 }
    public IEnumerator StunTime()
    {
        yield return(new WaitForSeconds(stunTime));

        aState      = actionState.idle;
        rb.velocity = Vector2.zero;
        Debug.Log(rb.velocity);
    }
    private void handleMovement()
    {
        bool called = false;

        if (Input.GetKey(up))
        {
            aState = actionState.running;
            //fix this it shoudl be a straight addition
            rb.position += (Vector2)transform.up * Time.deltaTime * moveSpeed;
            called       = true;
            if (Input.GetKey(down) || Input.GetKey(right) || Input.GetKey(left))
            {
                return;
            }
        }
        if (Input.GetKey(down))
        {
            aState       = actionState.running;
            rb.position -= (Vector2)transform.up * Time.deltaTime * moveSpeed;
            called       = true;
            if (Input.GetKey(up) || Input.GetKey(right) || Input.GetKey(left))
            {
                return;
            }
        }

        if (Input.GetKey(right))
        {
            aState       = actionState.running;
            rb.position += (Vector2)transform.right * Time.deltaTime * moveSpeed;
            called       = true;
            if (Input.GetKey(down) || Input.GetKey(up) || Input.GetKey(left))
            {
                return;
            }
        }

        if (Input.GetKey(left))
        {
            aState       = actionState.running;
            rb.position -= (Vector2)transform.right * Time.deltaTime * moveSpeed;
            called       = true;
            if (Input.GetKey(down) || Input.GetKey(right) || Input.GetKey(up))
            {
                return;
            }
        }

        if (called == false)
        {
            aState = actionState.idle;
        }
    }
    IEnumerator CheckCompletedDig(Vector2 startpos)
    {
        yield return(new WaitForSeconds(digTime));

        if (PassDig && aState == actionState.digging && rb.position == startpos)
        {
            aState = actionState.idle;
            if (OnSuccessfulDig != null)
            {
                OnSuccessfulDig(isRed, rb.position);
            }
        }
    }
Beispiel #6
0
    /*
     * Use the tool (gun, sword, etc.) and go through all the tool action states
     * This is in Character.cs because it is similar for every character
     */
    protected void toolUse()
    {
        if (toolActionState == actionState.telegraph && usingTool <= 0) //if we're in the telegraph phase and need to switch
        {
            //telegraph
            toolActionState++;                                //move to the next state
            usingTool = toolStates[(int)toolActionState - 1]; //set usingTool to the appropriate value

            useWeapons(toolUsed, playerHealthManager.characterDamageModifier);
            char toolType = getCurrentWeaponType();
            if (toolType == 'g' && toolUsed != 1 && this.gameObject.layer == 8)
            {
                toggleAnimRigging(false, true);
                //Debug.Log("setting rig.weight to zero cause we've got to wait " + (toolStates[1] + toolStates[2]) + " units of time before we can use it again");
            }
            toolUsed = 0;                                                 //we're done with this, set it up for next time.
        }
        else if (toolActionState == actionState.active && usingTool <= 0) //if we're using a tool and need to recover
        {
            //action
            toolActionState++;                                              //move to the next state
            usingTool = toolStates[(int)toolActionState - 1];               //set usingTool to the appropriate value
        }
        else if (toolActionState == actionState.recovery && usingTool <= 0) //if we are recovering and need to go to the cool down
        {
            //recovery
            toolActionState++;                                //move to the next state
            usingTool = toolStates[(int)toolActionState - 1]; //set usingTool to the appropriate value

            char toolType = getCurrentWeaponType();
            if (toolType == 'g' && this.gameObject.layer == 8)
            {
                //Debug.Log("turning on anim rigging");
                toggleAnimRigging(true, true);
            }
        }
        else if (toolActionState == actionState.cooldown && usingTool <= 0)
        {
            //cooldown
            toolActionState = actionState.inactive; //move to the inactive state
            usingTool       = 0;                    //set usingTool just to be safe and clean
        }
        else
        {
            usingTool--;
        }
    }
Beispiel #7
0
    //public float characterDamageModifier; // get the current damage modifier from the health manager

    // Start is called before the first frame update
    protected virtual void Start()
    {
        anim = GetComponentInChildren <Animator>();
        characterRigidbody = this.GetComponent <Rigidbody>(); //get rigidbody
        characterTransform = this.GetComponent <Transform>(); //get transform
        characterCollider  = this.GetComponent <Collider>();  //get collider

        jumpActionState = actionState.inactive;
        //toolActionState = actionState.inactive;

        // Get the characters health
        // Applies this script to each object using the character class
        // We can then generate a health bar based on this object by giving the name of the desired object
        playerHealthManager = gameObject.AddComponent <PlayerHealthController>();
        health = playerHealthManager.getHealth();
        isDead = false;

        isBlocking = false;
        //characterDamageModifier = playerHealthManager.characterDamageModifier;
    }
    private void handleOther()
    {
        if (Input.GetKeyDown(lightOn))
        {
            //  for the new raycast lights

            MeshRenderer MR;
            MR = GetComponentInChildren <MeshRenderer>();



            if (lState == lightState.lit)
            {
                MR.enabled = false;
                lState     = lightState.dark;
            }
            else
            {
                MR.enabled = true;
                lState     = lightState.lit;
            }
        }

        if (Input.GetKey(dig) == true && aState == actionState.idle && lState == lightState.lit)
        {
            aState  = actionState.digging;
            PassDig = true;
            StartCoroutine(CheckCompletedDig(rb.position));
        }


        if (Input.GetKeyDown(attackKey))
        {
            aState = actionState.attacking;
            animator.SetInteger("aState", (int)aState);
            Debug.Log("ATTACK PRESSED");
            Attack();
        }
    }
Beispiel #9
0
    // Switch cases for each stage of game and state of the party
    void Update()
    {
        switch (stage)
        {
        //This places four heroes into the party, gets their character stats and sets appropriate info, then sets the first waypoint and changes the enum states
        case dungeonStage.Preparing:
            methods.ResetParty(heroRoster, heroList);
            partySpeed = methods.GetPartySpeed(heroList);
            methods.FindTraps(trapList);
            wayPointNum = 0;
            target      = WayPointHolderScript.points[wayPointNum];
            FindObjectOfType <SoundControl>().SwitchMusic(true);
            FindObjectOfType <PadBehaviourScript>().ReturnToControlRoom();
            GameManager.invasion = true;
            //Sends the player to the control room
            //FindObjectOfType<PadBehaviourScript>().ReturnToControlRoom();
            stage = dungeonStage.Within;
            state = actionState.Exploring;
            break;

        //The main actions of the heroes will be decided here and will loop through until the situation changes
        case dungeonStage.Within:
            GameManager.dungeonEssence += (methods.ReleaseEssence(heroList)) / 4;
            //At any point inside the dungeon, if a hero gets too close to a trap, it will activate
            methods.TrapCheck(trapList, heroList, checkDelay);
            //Here the actions are based on the state enum
            switch (state)
            {
            //The leader will move towards the next waypoint, the followers will follow the leader
            case actionState.Exploring:
                if (wayPointNum == WayPointHolderScript.points.Length - 1)
                {
                    stage = dungeonStage.Leaving;
                }
                (target, wayPointNum) = methods.MoveToTarget(heroList[0].gameObject, target, partySpeed, 0.4f, wayPointNum);
                heroList[0].WalkAnim(true);
                for (int i = 0; i < heroList.Count - 1; i++)
                {
                    methods.FollowLeader(heroList[i].gameObject, heroList[i + 1].gameObject, partySpeed);
                    heroList[i + 1].WalkAnim(true);
                }
                //Performs a check of the party's surroundings every few seconds
                if (Time.time > timer)
                {
                    (enemyList, state) = methods.PerformCheck(heroList[0], enemyList);
                    timer = Time.time + checkDelay;
                }
                break;

            //Sets the characters' enemies, then allows them to fight until conclusion
            case actionState.Fighting:
                //While fighting, essence release is increased
                GameManager.dungeonEssence += methods.ReleaseEssence(heroList);
                if (methods.FearCheck(heroList))
                {
                    state = actionState.Fleeing; wayPointNum--;
                }
                //Checks if there are enemies in range, otherwise sets back to exploring
                if (enemyList.Count == 0)
                {
                    state = actionState.Exploring; break;
                }
                if (heroList.Count == 0)
                {
                    stage = dungeonStage.Leaving; break;
                }
                methods.SetEnemies(heroList, enemyList);

                for (int i = 0; i < heroList.Count; i++)
                {
                    heroList[i].WalkAnim(false);
                    //If there are no more enemies, the party resume exploring
                    if (enemyList.Count == 0)
                    {
                        state = actionState.Exploring; break;
                    }
                    if (heroList.Count == 0)
                    {
                        stage = dungeonStage.Leaving; break;
                    }
                    if (!heroList[i].HasEnemy())
                    {
                        heroList[i].Fight(checkDelay);
                    }
                    //Check the distance, then fight, otherwise move the character
                    if (methods.FightCheck(heroList[i]))
                    {
                        heroList[i].Fight(checkDelay);
                    }
                    else if (heroList[i])
                    {
                        methods.MoveToTarget(heroList[i]);
                    }
                }
                for (int j = 0; j < enemyList.Count; j++)
                {
                    //If the party wipes out, the stage is changed to the leaving stage
                    if (heroList.Count == 0)
                    {
                        stage = dungeonStage.Leaving; break;
                    }
                    if (enemyList.Count == 0)
                    {
                        state = actionState.Exploring; break;
                    }
                    if (!enemyList[j].HasEnemy())
                    {
                        enemyList[j].Fight(checkDelay);
                    }
                    if (methods.FightCheck(enemyList[j]))
                    {
                        enemyList[j].Fight(checkDelay);
                    }
                    else if (enemyList[j])
                    {
                        methods.MoveToTarget(enemyList[j]);
                    }
                }


                break;

            //When the collective fear of the party members is too much, the party will run away
            case actionState.Fleeing:
                if (wayPointNum <= 1)
                {
                    stage = dungeonStage.Leaving;
                }
                //Once the heroes begin to flee, they will run to the exit.
                wayPointNum = methods.RunAway(heroList[0].gameObject, partySpeed, 0.5f, wayPointNum);
                heroList[0].WalkAnim(true);
                for (int i = 0; i < heroList.Count - 1; i++)
                {
                    heroList[i + 1].WalkAnim(true);
                    methods.FollowLeader(heroList[i].gameObject, heroList[i + 1].gameObject, partySpeed);
                }
                break;
            }
            break;

        //This is where the heroes make further actions after reaching the end of their journey/ also when wiped by dungeon
        case dungeonStage.Leaving:
            //Returns all heroes to the starting area
            for (int i = 0; i < heroList.Count; i++)
            {
                heroList[i].transform.position = WayPointHolderScript.points[0].position;
            }
            heroList.Clear();
            //Restores the values for the heroes
            for (int i = 0; i < heroRoster.Length; i++)
            {
                heroRoster[i].GetComponent <CharacterScript>().Restore();
            }
            timer = Time.time + waitAmount;
            //Sets the stage to the Out setting
            stage = dungeonStage.Out;
            FindObjectOfType <SoundControl>().SwitchMusic(false);
            GameManager.invasion = false;
            break;

        //This will clear info and will then wait until next invasion of heroes
        case dungeonStage.Out:
            if (setting == waitSetting.Random)
            {
                timer += Random.Range(-timer, timer); setting = waitSetting.SetAmount;
            }
            if (methods.WaitCheck(timer, setting))
            {
                stage = dungeonStage.Preparing;
            }
            break;
        }
    }