public virtual void Init(bool isPlayerOne, GameObject otherFighter)
    {
        GameObject canvas = GameObject.FindGameObjectWithTag("Canvas");

        gameManager            = GameObject.FindGameObjectWithTag("Game Manager").GetComponent <GameManager>();
        rb                     = GetComponent <Rigidbody>();
        this.isPlayerOne       = isPlayerOne;
        this.otherFighter      = otherFighter;
        otherFighterController = otherFighter.GetComponent <FighterController>();
        fighterControllerState = FighterControllerState.DetermineFighterControllerState(this);

        if (isPlayerOne)
        {
            controllerInput = ControllerManager.GetControllerInput(1);
            fighterUI       = canvas.transform.GetChild(0).GetComponent <FighterUI>();
        }
        else
        {
            controllerInput = ControllerManager.GetControllerInput(2);
            fighterUI       = canvas.transform.GetChild(1).GetComponent <FighterUI>();
        }
        anim          = GetComponent <Animator>();
        attackManager = GetComponent <AttackManager>();
        attackManager.Init();
        fighterUI.Init();

        startingPosition.Set(transform.position.x, transform.position.y, transform.position.z);
        startingRotation.Set(transform.rotation.x, transform.rotation.y, transform.rotation.z, transform.rotation.w);
        startingScale.Set(transform.localScale.x, transform.localScale.y, transform.localScale.z);
    }
Exemplo n.º 2
0
    void Start()
    {
        Physics.gravity = new Vector3(0, -7f, 0);
        gameObject.GetComponent <ControllerManager>().Init();
        roundsToWin         = GameData.GetNumberOfRounds();
        canvas              = GameObject.FindGameObjectWithTag("Canvas").GetComponent <Canvas>();
        fighterOneUiObject  = canvas.transform.GetChild(0).gameObject;
        fighterTwoUiObject  = canvas.transform.GetChild(1).gameObject;
        gameUiObject        = canvas.transform.GetChild(2).gameObject;
        fighterSpeechText   = canvas.transform.GetChild(3).gameObject.GetComponent <Text>();
        rematchMenuUiObject = canvas.transform.GetChild(4).gameObject;
        pauseMenuObject     = canvas.transform.GetChild(5).gameObject;
        playerOnePaused     = false;
        fighterOneName.text = "" + GameData.GetFighterOneCharacter();
        fighterTwoName.text = "" + GameData.GetFighterTwoCharacter();
        GameObject fighterOneToClone = DecideFighter(GameData.GetFighterOneCharacter());
        GameObject fighterTwoToClone = DecideFighter(GameData.GetFighterTwoCharacter());
        GameObject fighterOneClone;
        GameObject fighterTwoClone;

        if (GameData.GetFighterOneCharacter() == characters.Nesua)
        {
            fighterOneClone = Instantiate(fighterOneToClone, fighterOneStartingPosition, fighterOneStartingRotationNew);
        }
        else
        {
            fighterOneClone = Instantiate(fighterOneToClone, fighterOneStartingPosition, fighterOneStartingRotation);
        }
        if (GameData.GetFighterTwoCharacter() == characters.Nesua)
        {
            fighterTwoClone = Instantiate(fighterTwoToClone, fighterTwoStartingPosition, fighterTwoStartingRotationNew);
        }
        else
        {
            fighterTwoClone = Instantiate(fighterTwoToClone, fighterTwoStartingPosition, fighterTwoStartingRotation);
        }
        fighterOneClone.SetActive(true);
        fighterTwoClone.SetActive(true);
        fighterOne = fighterOneClone.GetComponent <FighterController>();
        fighterTwo = fighterTwoClone.GetComponent <FighterController>();
        fighterOne.Init(true, fighterTwoClone);
        fighterTwo.Init(false, fighterOneClone);
        fighterOneUI = fighterOne.GetFighterUI();
        fighterTwoUI = fighterTwo.GetFighterUI();
        mainCamera.Init(fighterOneClone, fighterTwoClone);
        zoomInCamera.Init();
        menuNavigation = GetComponent <MenuNavigation>();
        StartGame();
    }
Exemplo n.º 3
0
    public void CopyFighter(Fighter fighter)
    {
        this.CopyCreature(fighter);

        this.nHealthMax      = fighter.nHealthMax;
        this.nCurrentHealth  = fighter.nCurrentHealth;
        this.nPower          = fighter.nPower;
        this.bIsImportant    = fighter.bIsImportant;
        this.currentUI       = fighter.currentUI;
        this.justTookDamage  = fighter.justTookDamage;
        this.bHasbeenAttcked = fighter.bHasbeenAttcked;
        this.bHasTookDamage  = fighter.bHasTookDamage;
        // this.nInitiative = fighter.nInitiative;
        // this.nArmor = fighter.nArmor;
        // this.nPrecision = fighter.nPrecision;
    }
Exemplo n.º 4
0
    public virtual void PerformActionOnTarget(ActionType action, Fighter fighter)
    {
        performingAction = true;
        justdidAction    = true;
        lastAction       = action;

        lastAttackedUI = fighter.currentUI;

        if (fighter == null || fighter.sName == null)
        {
            Debug.Log("Fighter :" + this.sName + "  Perform action :" + action.sName);
        }
        else
        {
            Debug.Log("Fighter :" + this.sName + "  Perform action :" + action.sName + "on target " + fighter.sName);
        }

        if (action == ActionType.ATTACK)
        {
            CombatManager combatManager = GameObject.FindGameObjectWithTag("CombatManager").GetComponent <CombatManager>();

            // float rand = 0.5f;
            float rand = Random.Range(0f, 1f);

            float terrain = GameObject.FindGameObjectWithTag("CombatTerrain").GetComponent <CombatTerrainInfo>().modRoll.GetValueOfAction(action, this.eCreatureType);
            rand += terrain;

            if (this.eCreatureType == CreatureType.Human)
            {
                if (!combatManager.humanGroupFighter.bIsSpecial)
                {
                    float bonus = GameObject.FindGameObjectWithTag("TipManager").GetComponent <TipsManager>().GetBonus(action, (Human)this, (GroupMonsterFighter)combatManager.monsterGroupFighter);

                    rand += bonus;
                }
            }


            if (combatManager.protoScript != null && combatManager.protoScript.combat != null && combatManager.protoScript.combat.currentTurn != null)
            {
                float l = combatManager.protoScript.combat.currentTurn.fRoll;
                if (l != 0)
                {
                    rand = l;
                }
            }

            if (combatManager.humanGroupFighter.bIsSpecial)
            {
                rand = 0.5f;
            }
            int damage = this.GetDamage();

            if (eCreatureType == CreatureType.Human && !combatManager.humanGroupFighter.bIsSpecial)
            {
                float damageMod = GameObject.FindGameObjectWithTag("TipManager").GetComponent <TipsManager>().GetBonusDmg((Human)this, (GroupMonsterFighter)combatManager.monsterGroupFighter);
                if (damageMod != 0)
                {
                    damage /= 2;
                }
            }

            if (rand >= combatManager.rollProbaManager.Attack.normal)
            {
                fighter.TakeDamage(damage * 2);
                AkSoundEngine.PostEvent("Play_" + sName + "_crit", GameObject.FindGameObjectWithTag("MainCamera"));

                lastActionResult = RollResultEnum.Crit;
            }
            else if (rand > combatManager.rollProbaManager.Attack.fail)
            {
                fighter.TakeDamage(damage);

                if (this.eCreatureType == CreatureType.Monster)
                {
                    AkSoundEngine.PostEvent("Play_" + "merchant" + "_hit", GameObject.FindGameObjectWithTag("MainCamera"));
                }
                else
                {
                    AkSoundEngine.PostEvent("Play_" + sName + "_hit", GameObject.FindGameObjectWithTag("MainCamera"));
                }

                lastActionResult = RollResultEnum.Normal;
            }
            else
            {
                lastActionResult = RollResultEnum.Fail;

                if (eCreatureType == CreatureType.Human)
                {
                    if (combatManager.protoScript != null && combatManager.protoScript.combat != null && combatManager.protoScript.combat.currentTurn != null)
                    {
                        if (combatManager.protoScript.combat.index < 7)
                        {
                            combatManager.protoScript.combat.HumainFailAttack();
                        }
                    }
                }


                Debug.Log("Fail");
                AkSoundEngine.PostEvent("Play_miss", GameObject.FindGameObjectWithTag("MainCamera"));
                GameObject    g  = GameObject.FindGameObjectWithTag("CombatManager");
                CombatManager cm = g.GetComponent <CombatManager>();

                if (fighter.eCreatureType == CreatureType.Monster)
                {
                    ((GroupMonsterFighter)cm.GetGroupFighterOfFighter(fighter)).OneFighterGotTargetted();
                }
                else
                {
                    ((GroupHumanFighter)cm.GetGroupFighterOfFighter(fighter)).OneFighterGotTargetted();
                }
                ActionTalk(action, rand);
            }

            if (fighter.eCreatureType == CreatureType.Monster)
            {
                if (combatManager.protoScript != null && combatManager.protoScript.combat != null && combatManager.protoScript.combat.currentTurn != null)
                {
                    if (combatManager.protoScript.combat.nbAttack == 0 || (combatManager.protoScript.combat.nbAttack == 1 && combatManager.protoScript.combat.roundIt == 3) ||
                        combatManager.protoScript.combat.nbAttack == 2 || combatManager.protoScript.combat.nbAttack == 3)
                    {
                        combatManager.protoScript.combat.HumanAttack();
                    }
                }
            }


            // ActionTalk(action, rand);
        }
    }