Ejemplo n.º 1
0
 // Use this for initialization
 void Start()
 {
     _enemyBody          = GetComponent <Rigidbody2D>();
     _patrolRouteService = PatrolArea.GetComponent <PatrolRouteService>();
     _combatController   = GetComponent <EnemyCombatController>();
     Anim = GetComponentInChildren <Animation>();
 }
Ejemplo n.º 2
0
    public void OnPlayerActivatedCommand(SkillDescriptor skillDescriptor)
    {
        HideAllButtons();

        CommandBase.Target        skillTargets = skillDescriptor.targets;
        List <CommandBase.Target> targets      = new List <CommandBase.Target>();

        foreach (CommandBase.Target target in (CommandBase.Target[])System.Enum.GetValues(typeof(CommandBase.Target)))
        {
            if ((skillTargets & target) > 0)
            {
                targets.Add(target);
            }
        }
        int defaultTargetIndex = targets.IndexOf(skillDescriptor.startTarget);

        if (defaultTargetIndex < 0)
        {
            defaultTargetIndex = 0;
        }
        selectedCommand = new LoadedCommand(skillDescriptor.displayText, activePlayer, skillDescriptor.delay, 0, skillDescriptor.manaCost, targets.ToArray(), defaultTargetIndex, skillDescriptor.isRetargetable, skillDescriptor.effects);

        lastSingleEnemyCombatTarget  = null;
        lastSinglePlayerCombatTarget = null;

        lastSingleEnemyCombatTarget  = RightEnemy();
        lastSinglePlayerCombatTarget = activePlayer;
    }
Ejemplo n.º 3
0
 protected virtual void Start()
 {
     MovementController = new PatrollingEnemyMovementController(gameObject, WalkingSpeed);
     CombatController   = new EnemyCombatController(gameObject, MaxLife);
     if (Patrolling)
     {
         StartPatrolling();
     }
 }
Ejemplo n.º 4
0
	// Use this for initialization
	void Start () {
		enemyMonster = GameObject.FindObjectOfType<EnemyMonster>();
		enemyCombatController = GameObject.FindObjectOfType<EnemyCombatController>();

		actionBarImage = GetComponent<Image>();
		actionBarRectTransform = GetComponent<RectTransform>();

		randomChanceOfSecondSkill = Random.value;
	}
    public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        _brain  = animator.GetComponent <EnemyBrainController>();
        _combat = animator.GetComponent <EnemyCombatController>();
        _motor  = animator.GetComponent <EnemyMotorController>();
        _agent  = animator.GetComponent <NavMeshAgent>();

        _motor.StartFollow();
    }
Ejemplo n.º 6
0
    EnemyCombatController LeftEnemy()
    {
        EnemyCombatController left = null;
        float currentX             = float.MaxValue;

        foreach (EnemyCombatController enemy in battleController.enemyActors)
        {
            float ex = enemy.transform.position.x;
            if (ex < currentX)
            {
                currentX = ex;
                left     = enemy;
            }
        }
        return(left);
    }
Ejemplo n.º 7
0
    EnemyCombatController RightEnemy()
    {
        EnemyCombatController right = null;
        float currentX = float.MinValue;

        foreach (EnemyCombatController enemy in battleController.enemyActors)
        {
            float ex = enemy.transform.position.x;
            if (ex > currentX)
            {
                currentX = ex;
                right    = enemy;
            }
        }
        return(right);
    }
Ejemplo n.º 8
0
    EnemyCombatController TopEnemy()
    {
        EnemyCombatController top = null;
        float currentY            = float.MinValue;

        foreach (EnemyCombatController enemy in battleController.enemyActors)
        {
            float ey = enemy.transform.position.y;
            if (ey > currentY)
            {
                currentY = ey;
                top      = enemy;
            }
        }
        return(top);
    }
Ejemplo n.º 9
0
    EnemyCombatController BottomEnemy()
    {
        EnemyCombatController bottom = null;
        float currentY = float.MaxValue;

        foreach (EnemyCombatController enemy in battleController.enemyActors)
        {
            float ey = enemy.transform.position.y;
            if (ey < currentY)
            {
                currentY = ey;
                bottom   = enemy;
            }
        }
        return(bottom);
    }
Ejemplo n.º 10
0
    public SkillDescriptor ChooseSkill()
    {
        int                    runningTotal    = 0;
        List <int>             thresholds      = new List <int>();
        List <SkillDescriptor> candidateSkills = new List <SkillDescriptor>();

        for (int i = 0; i < skills.Length; i++)
        {
            EnemyCombatController ecc = GetComponent <EnemyCombatController>();
            if (skills[i].manaCost <= ecc.entity.mana)
            {
                //HACK
                //temp fix to weights not being used
                //thresholds.Add(weights[i]);
                thresholds.Add(1);
                candidateSkills.Add(skills[i]);
                //runningTotal += weights[i];
                runningTotal += 1;
            }
        }

        if (candidateSkills.Count == 0)
        {
            return(null);
        }

        int diceRoll = Random.Range(0, runningTotal);

        for (int i = 1; i < thresholds.Count; i++)
        {
            if (thresholds[i] >= diceRoll)
            {
                return(candidateSkills[i - 1]);
            }
        }
        return(candidateSkills[candidateSkills.Count - 1]);
    }
Ejemplo n.º 11
0
 private void Start()
 {
     enemyController = this.GetComponent <EnemyCombatController>();
     pickupableEnemy = this.GetComponent <PickupableObject>();
     pickupableEnemy.CanBePickedUpAtMoment = false;
 }
Ejemplo n.º 12
0
 private void Awake()
 {
     _stats  = GetComponent <EnemyStatsController>();
     _combat = GetComponent <EnemyCombatController>();
 }
Ejemplo n.º 13
0
    private EnemyCombatController NextEnemy(TargetChangeDirection change)
    {
        float currentX = lastSingleEnemyCombatTarget.transform.position.x;
        float nx       = currentX;
        float currentY = lastSingleEnemyCombatTarget.transform.position.y;
        float ny       = currentY;
        EnemyCombatController nextEnemy = null;

        switch (change)
        {
        case TargetChangeDirection.Left:
            foreach (EnemyCombatController enemy in battleController.enemyActors)
            {
                float ex = enemy.transform.position.x;
                if (ex < currentX && (ex > nx || nx == currentX))
                {
                    nx        = ex;
                    nextEnemy = enemy;
                }
            }
            return(nextEnemy);

        case TargetChangeDirection.Right:
            foreach (EnemyCombatController enemy in battleController.enemyActors)
            {
                float ex = enemy.transform.position.x;
                if (ex > currentX && (ex > nx || nx == currentX))
                {
                    nx        = ex;
                    nextEnemy = enemy;
                }
            }
            return(nextEnemy);

        case TargetChangeDirection.Up:
            foreach (EnemyCombatController enemy in battleController.enemyActors)
            {
                float ey = enemy.transform.position.y;
                if (ey > currentY && (ey > ny || ny == currentY))
                {
                    ny        = ey;
                    nextEnemy = enemy;
                }
            }
            if (nextEnemy == null)
            {
                nextEnemy = BottomEnemy();
            }
            return(nextEnemy);

        case TargetChangeDirection.Down:
            foreach (EnemyCombatController enemy in battleController.enemyActors)
            {
                float ey = enemy.transform.position.y;
                if (ey < currentY && (ey < ny || ny == currentY))
                {
                    ny        = ey;
                    nextEnemy = enemy;
                }
            }
            if (nextEnemy == null)
            {
                nextEnemy = TopEnemy();
            }
            return(nextEnemy);

        default:
            throw new System.ArgumentException("Unhandled switch case [" + change.ToString() + "]");
        }
    }
Ejemplo n.º 14
0
    private void ManageTargetSelectionInput()
    {
        switch (selectedCommand.currentTargetSelection)
        {
        case CommandBase.Target.ALL_ALLIES:
            //  Left: previous target option
            //  Right/Up/Down: Nothing
            if (Input.GetButtonDown("MoveLeft"))
            {
                selectedCommand.currentTargetIndex--;
            }
            break;

        case CommandBase.Target.SELECTED_ALLY:
            //  Left: previous target option
            //  Right: next target option
            //  Up/Down: Toggle targets
            if (Input.GetButtonDown("MoveLeft"))
            {
                selectedCommand.currentTargetIndex--;
            }
            if (Input.GetButtonDown("MoveRight"))
            {
                selectedCommand.currentTargetIndex++;
            }
            if (Input.GetButtonDown("MoveUp"))
            {
                lastSinglePlayerCombatTarget = NextPlayer(TargetChangeDirection.Up);
            }
            if (Input.GetButtonDown("MoveDown"))
            {
                lastSinglePlayerCombatTarget = NextPlayer(TargetChangeDirection.Down);
            }
            break;

        case CommandBase.Target.SELF:
            //  As SELECTED_ALLY but Up/Down does nothing
            if (Input.GetButtonDown("MoveLeft"))
            {
                selectedCommand.currentTargetIndex--;
            }
            if (Input.GetButtonDown("MoveRight"))
            {
                selectedCommand.currentTargetIndex++;
            }
            break;

        case CommandBase.Target.SELECTED_ENEMY:
            //  Left: Previous single enemy target if one available, or previous target option otherwise
            //  Right: Next single enemy target if one availalbe, or next target option otherwise
            //  Up/Down: Vertical toggle on targets (wraparound possible)
            if (Input.GetButtonDown("MoveLeft"))
            {
                EnemyCombatController nextEnemy = NextEnemy(TargetChangeDirection.Left);
                if (nextEnemy == null)
                {
                    selectedCommand.currentTargetIndex--;
                }
                else
                {
                    lastSingleEnemyCombatTarget = nextEnemy;
                }
            }
            if (Input.GetButtonDown("MoveRight"))
            {
                EnemyCombatController nextEnemy = NextEnemy(TargetChangeDirection.Right);
                if (nextEnemy == null)
                {
                    selectedCommand.currentTargetIndex++;
                }
                else
                {
                    lastSingleEnemyCombatTarget = nextEnemy;
                }
            }
            if (Input.GetButtonDown("MoveUp"))
            {
                lastSingleEnemyCombatTarget = NextEnemy(TargetChangeDirection.Up);
            }
            if (Input.GetButtonDown("MoveDown"))
            {
                lastSingleEnemyCombatTarget = NextEnemy(TargetChangeDirection.Down);
            }
            break;

        case CommandBase.Target.ALL_ENEMIES:
            //  Right: Next target option
            //  Left/Up/Down: Nothing
            if (Input.GetButtonDown("MoveRight"))
            {
                selectedCommand.currentTargetIndex++;
            }
            break;

        case CommandBase.Target.RANDOM_ENEMY:
            // No input to handle
            //  This should never apply here; if RANDOM_ENEMY is in the list,
            //  it should be alone, and a random enemy should be selected instead
            break;
        }
    }
Ejemplo n.º 15
0
    private void EditEntity()
    {
        EnemyCombatController ecc = Selection.activeGameObject.GetComponent <EnemyCombatController>();
        Entity temp = ecc.entity;

        if (temp == null)
        {
            GUILayout.Label("No monster data found.  Create new data or assign existing.");
            if (GUILayout.Button("Create Data"))
            {
                temp      = ScriptableObject.CreateInstance <Entity>() as Entity;
                temp.name = Selection.activeGameObject.name + "_data.asset";
                string targetPath = @"Assets\RPG System\Prefabs\Monsters\MonsterData\" + temp.name;
                if (AssetDatabase.LoadAssetAtPath(targetPath, typeof(Entity)) == null)
                {
                    AssetDatabase.CreateAsset(temp, @"Assets\RPG System\Prefabs\Monsters\MonsterData\" + temp.name);
                    SerializedObject   eccAsset  = new SerializedObject(ecc);
                    SerializedProperty eccEntity = eccAsset.FindProperty("entity");
                    eccEntity.objectReferenceValue = temp;
                    eccAsset.ApplyModifiedProperties();
                }
                else
                {
                    Debug.LogError("Name clash with assets!  " + targetPath + " already exists! Use picker instead?");
                }
            }
        }
        else
        {
            SerializedObject   eccAsset         = new SerializedObject(Selection.activeGameObject.GetComponent <EnemyCombatController>());
            SerializedProperty monsterDataAsset = eccAsset.FindProperty("entity");
            monsterDataAsset.objectReferenceValue = EditorGUILayout.ObjectField("Data:", monsterDataAsset.objectReferenceValue, typeof(Entity), false);

            //HACK
            if (monsterDataAsset.objectReferenceValue == null)
            {
                //need to save and bail to bring up the create data option
                eccAsset.ApplyModifiedProperties();
                return;
            }

            Entity           currentEntity = monsterDataAsset.objectReferenceValue as Entity;
            SerializedObject monsterStats  = new SerializedObject(currentEntity);

            SerializedProperty currentStat = monsterStats.FindProperty("strengthBase");
            currentStat.intValue = EditorGUILayout.IntField("Strength", currentStat.intValue);

            currentStat          = monsterStats.FindProperty("constitutionBase");
            currentStat.intValue = EditorGUILayout.IntField("Constitution", currentStat.intValue);

            currentStat          = monsterStats.FindProperty("intelligenceBase");
            currentStat.intValue = EditorGUILayout.IntField("Intelligence", currentStat.intValue);

            currentStat          = monsterStats.FindProperty("willpowerBase");
            currentStat.intValue = EditorGUILayout.IntField("Willpower", currentStat.intValue);

            currentStat          = monsterStats.FindProperty("physicalArmorBase");
            currentStat.intValue = EditorGUILayout.IntField("Physical Armor", currentStat.intValue);

            currentStat          = monsterStats.FindProperty("magicArmorBase");
            currentStat.intValue = EditorGUILayout.IntField("Magic Armor", currentStat.intValue);

            currentStat          = monsterStats.FindProperty("entityLevel");
            currentStat.intValue = EditorGUILayout.IntField("Level", currentStat.intValue);

            //All done editing
            currentEntity.ResetStatsToBase();
            currentEntity.CalculateAllStats();
            currentEntity.FullHeal();
            eccAsset.ApplyModifiedProperties();
            monsterStats.ApplyModifiedProperties();

            //Display Read-only properties
            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Calculated Properties");
            EditorGUI.indentLevel += 1;
            EditorGUILayout.LabelField("HP: " + currentEntity.hitPoints);
            EditorGUILayout.LabelField("Endurance: " + currentEntity.endurance);
            EditorGUILayout.LabelField("Mana: " + currentEntity.mana);
            EditorGUI.indentLevel -= 1;
        }
    }