コード例 #1
0
    virtual public void InitializeEnemy()
    {
        //creating variables to initialize the monster
        //this code is for testing purposes, final product will pull this information from the database scripts
        var headInfo     = PartFactory.GetHeadPartInfo(monsterName);
        var torsoInfo    = PartFactory.GetTorsoPartInfo(monsterName);
        var rightArmInfo = PartFactory.GetArmPartInfo(monsterName, Helper.PartType.RightArm);
        var leftArmInfo  = PartFactory.GetArmPartInfo(monsterName, Helper.PartType.LeftArm);
        var legPartInfo  = PartFactory.GetLegPartInfo(monsterName);

        rightArmInfo.equippedWeapon = equippedWeapon;

        attackDelegate  = Attack;
        abilityDelegate = Ability;

        //adding methods to be run in fixed update to the check delegate
        //this allows multiple methods that need to constantly check some status of the Enemy
        //to be run in FixedUpdate without filling it with method calls
        checkDelegate += UpdateCooldowns;
        checkDelegate += CheckLineOfSight;
        checkDelegate += CheckAggro;
        checkDelegate += FollowTarget;

        monster.InitializeMonster(headInfo, torsoInfo, rightArmInfo, leftArmInfo, legPartInfo);
        //setting the cooldown timers so that the player can use the inputs as soon as the game loads
        attackCooldownTimer  = attackCooldown;
        abilityCooldownTimer = abilityCooldown;

        SetFacingDirection(transform.localScale.x);
    }
コード例 #2
0
    public void InitializePart(TorsoPartInfo torsoPartInfo)
    {
        //this mainly is used to check whether the part is attached to the player
        PlayerController player = GetComponentInParent <PlayerController>();

        if (torsoPartInfo != null)
        {
            partInfo = torsoPartInfo;

            //checking whether this part has an ability
            if (partInfo.abilityName != null && player != null)
            {
                //populating the partAbility field with the appropriate ability delegate
                partAbility = AbilityFactory.GetPartAbility(partInfo.abilityName);

                //if the type is Passive, run the delegate method to apply the buff to the player
                if (partInfo.abilityType == "Passive")
                {
                    partAbility();
                }//if the type is Activate, set the ability to the Player action delegate
                else if (partInfo.abilityType == "Activate")
                {
                    player.torsoAbilityDelegate = partAbility;
                }
            }

            if (GetComponentInParent <Enemy>() == null)
            {
                bodySprite = Helper.CreateSprite(partInfo.mainSprite, Helper.TorsoImporter);
            }

            body.sprite = bodySprite;
        }
    }
コード例 #3
0
    public void InitializePart(LegPartInfo legPartInfo)
    {
        //this mainly is used to check whether the part is attached to the player
        PlayerController player = GetComponentInParent <PlayerController>();

        if (legPartInfo != null)
        {
            partInfo = legPartInfo;

            //populating the partAbility field
            if (partInfo.abilityName != null && player != null)
            {
                partAbility = AbilityFactory.GetPartAbility(partInfo.abilityName);

                //if the type is Passive, run the delegate method to apply the buff to the player
                if (partInfo.abilityType == "Passive")
                {
                    partAbility();
                }//if the type is Activate, set the ability to the Player action delegate
                else if (partInfo.abilityType == "Activate")
                {
                    player.jumpDelegate = partAbility;
                }
            }

            if (GetComponentInParent <Enemy>() == null)
            {
                pelvisSprite = Helper.CreateSprite(partInfo.pelvisSprite, Helper.PelvisImporter);
                thighSprite  = Helper.CreateSprite(partInfo.thighSprite, Helper.ThighImporter);
                shinSprite   = Helper.CreateSprite(partInfo.shinSprite, Helper.ShinImporter);
                footSprite   = Helper.CreateSprite(partInfo.footSprite, Helper.FootImporter);
            }

            pelvis.sprite = pelvisSprite;
            thighR.sprite = thighSprite;
            thighL.sprite = thighSprite;
            shinR.sprite  = shinSprite;
            shinL.sprite  = shinSprite;
            footR.sprite  = footSprite;
            footL.sprite  = footSprite;
        }
    }
コード例 #4
0
    public void InitializePlayer()
    {
        //creating variables to initialize the player monster
        //this code is for testing purposes, final product will pull this information from the database scripts

        HeadPartInfo  headInfo     = new HeadPartInfo();
        TorsoPartInfo torsoInfo    = new TorsoPartInfo();
        ArmPartInfo   rightArmInfo = new ArmPartInfo();
        ArmPartInfo   leftArmInfo  = new ArmPartInfo();
        LegPartInfo   legPartInfo  = new LegPartInfo();

        //initializing the Head
        if (head != "")
        {
            headInfo = PartFactory.GetHeadPartInfo(head);
        }
        else
        {
            headInfo = GameManager.instance.gameFile.player.headPart;
        }
        //initializing the Torso
        if (torso != "")
        {
            torsoInfo = PartFactory.GetTorsoPartInfo(torso);
        }
        else
        {
            torsoInfo = GameManager.instance.gameFile.player.torsoPart;
        }
        //initializing the RightArm
        if (rightArm != "")
        {
            rightArmInfo = PartFactory.GetArmPartInfo(rightArm, Helper.PartType.RightArm);
            rightArmInfo.equippedWeapon = rightWeapon;
        }
        else
        {
            rightArmInfo = GameManager.instance.gameFile.player.rightArmPart;
        }
        //initializing the LeftArm
        if (leftArm != "")
        {
            leftArmInfo = PartFactory.GetArmPartInfo(leftArm, Helper.PartType.LeftArm);
            leftArmInfo.equippedWeapon = leftWeapon;
        }
        else
        {
            leftArmInfo = GameManager.instance.gameFile.player.leftArmPart;
        }
        //initializing the Legs
        if (legs != "")
        {
            legPartInfo = PartFactory.GetLegPartInfo(legs);
        }
        else
        {
            legPartInfo = GameManager.instance.gameFile.player.legsPart;
        }


        moveDelegate         = Move;
        jumpDelegate         = Jump;
        rightAttackDelegate  = RightAttack;
        leftAttackDelegate   = LeftAttack;
        torsoAbilityDelegate = AbilityDefault;
        headAbilityDelegate  = AbilityDefault;

        playerCheckDelegate += UpdatePlayerDirection;
        playerCheckDelegate += UpdatePlayerInputCooldowns;
        playerCheckDelegate += CheckHitBox;

        monster.InitializeMonster(headInfo, torsoInfo, rightArmInfo, leftArmInfo, legPartInfo);

        SetPlayerCooldowns();
        //setting the cooldown timers so that the player can use the inputs as soon as the game loads
        rightAttackTimer  = RightAttackCooldown;
        leftAttackTimer   = LeftAttackCooldown;
        headAbilityTimer  = HeadAbilityCooldown;
        torsoAbilityTimer = TorsoAbilityCooldown;
        legAbilityTimer   = LegAbilityCooldown;
    }