Example #1
0
 public virtual void User_OnCreatureMovementFinished(BJCreatureObject creatureObject)
 {
     if (creatureObject.CurrentSkill != this)           // whoops :(
     {
         return;
     }
 }
Example #2
0
 public override void User_OnCreatureMovementFinished(BJCreatureObject creatureObject)
 {
     base.User_OnCreatureMovementFinished(creatureObject);
     if (creatureObject.CurrentSkill != this)           // whoops :(
     {
         return;
     }
     moveCounter++;
     if (moveCounter == 1)
     {
         CurrentUser.Creature.ArmorPierce += Damage;
         CurrentUser.DealDamage(CurrentUser.Creature.BaseDamage, 1.0f, CurrentMainTarget);
         for (int i = 0; i < Effects.Count; i++)
         {
             if (Random.Range(0.0f, 0.99f) < EffectChances [i])
             {
                 Effects [i].Applier = CurrentUser;
                 CurrentMainTarget.ApplyEffect(Effects [i], true);
             }
         }
         CurrentUser.Creature.ArmorPierce -= Damage;
         CurrentUser.MoveToPoint(CurrentUser.InitialPosition);
     }
     if (moveCounter == 2)
     {
         StartCoroutine(FinishSkill(0.1f));
     }
 }
Example #3
0
 public void SpawnCreatures(int amount)
 {
     if (Player.Instance != null)           // kostyll
     {
         List <CreatureData> enemyShipDatas = Player.Instance.CurrentMission.EnemyShips;
         for (int i = 0; i < enemyShipDatas.Count; i++)
         {
             BJCreature       enemyCreature    = enemyShipDatas [i].Creature;
             BJCreatureObject bjCreatureObject = SpawnCreatureObject(enemyCreature, enemyShipDatas [i].Level);
             bjCreatureObject.gameObject.transform.SetParent(EnemySpawnPoints [i]);
             bjCreatureObject.gameObject.transform.localScale    = Vector3.one;
             bjCreatureObject.gameObject.transform.localPosition = Vector3.zero;
         }
     }
     else
     {
         List <BJCreature> enemyCreatures = new List <BJCreature> (BJPlayer.Instance.DataBase.EnemyCreatures);
         for (int i = 0; i < amount; i++)
         {
             BJCreatureObject bjCreatureObject = SpawnCreatureObject(enemyCreatures [i], 1);
             bjCreatureObject.gameObject.transform.SetParent(EnemySpawnPoints [i]);
             bjCreatureObject.gameObject.transform.localScale    = Vector3.one;
             bjCreatureObject.gameObject.transform.localPosition = Vector3.zero;
         }
     }
 }
Example #4
0
    BJCreatureObject SpawnCreatureObject(BJCreature creature, int level)
    {
        GameObject       creatureObject   = Instantiate(CreatureObjectPrefab) as GameObject;
        BJCreatureObject bjCreatureObject = creatureObject.GetComponent <BJCreatureObject> ();

        bjCreatureObject.Creature       = new BJCreature(creature.Name, creature.MaxHPByLevel, creature.HP, creature.BaseDamageByLevel, creature.Armor, creature.Speed, creature.Allegiance, /*attackType,*/ creature.SkillNames);
        bjCreatureObject.Creature.Level = level;
        //Debug.Log (creature.Name + ": " + creature.HP);
        //bjCreatureObject.Creature.HP = bjCreatureObject.Creature.MaxHP;
        //Debug.Log (creature.Name + ": " + bjCreatureObject.Creature.HP);
        bjCreatureObject.Creature.IsDead = false;

        bjCreatureObject.CreatureImage.sprite = BJPlayer.Instance.DataBase.FigurinesByNames [creature.Name];
        bjCreatureObject.CreatureImage.SetNativeSize();
        bjCreatureObject.CreatureImage.rectTransform.sizeDelta = new Vector2(bjCreatureObject.CreatureImage.rectTransform.rect.width / 7,
                                                                             bjCreatureObject.CreatureImage.rectTransform.rect.height / 7);
        bjCreatureObject.HPFill.color = (creature.Allegiance == Allegiance.Player) ? Color.green : Color.red;
        foreach (var skillName in creature.SkillNames)
        {
            BJPlayer.Instance.DataBase.BJSkillsByNames [skillName].Name = skillName;
            bjCreatureObject.AddSkill(BJPlayer.Instance.DataBase.BJSkillsByNames [skillName]);
        }
        if (creature.Allegiance == Allegiance.Enemy)
        {
            EnemyCreatureObjects.Add(bjCreatureObject);
        }
        else
        {
            PlayerCreatureObjects.Add(bjCreatureObject);
        }
        bjCreatureObject.OnCreatureObjectClicked += BjCreatureObject_OnCreatureObjectClicked;
        bjCreatureObject.OnCreatureReadyForTurn  += BjCreatureObject_OnCreatureReadyForTurn;
        bjCreatureObject.OnCreatureTurnFinished  += BjCreatureObject_OnCreatureTurnFinished;
        return(bjCreatureObject);
    }
Example #5
0
    public override void UseSkill(BJCreatureObject user, BJCreatureObject mainTarget)
    {
        base.UseSkill(user, mainTarget);
        CurrentUser       = user;
        CurrentMainTarget = mainTarget;

        List <BJCreatureObject> ourCreatureObjects = (CurrentUser.Creature.Allegiance == Allegiance.Player) ? BJGameController.Instance.PlayerCreatureObjects : BJGameController.Instance.EnemyCreatureObjects;
        List <BJCreatureObject> secondaryTargets   = new List <BJCreatureObject> ();

        foreach (var creatureObject in ourCreatureObjects)
        {
            if (creatureObject != user && TargetPriorities.ContainsKey(ourCreatureObjects.IndexOf(creatureObject)) && creatureObject.Creature.HP > 0)
            {
                secondaryTargets.Add(creatureObject);
            }
        }
        Effects [0].Applier = user;
        mainTarget.ApplyEffect(Effects [0], true);
        foreach (var secondaryTarget in secondaryTargets)
        {
            Effects [0].Applier = user;
            secondaryTarget.ApplyEffect(Effects [0], true);
        }
        StartCoroutine(FinishSkill(0.1f));
    }
Example #6
0
    // public BJEffect ArmorBuffEffect;

    public override void UseSkill(BJCreatureObject user, BJCreatureObject mainTarget)
    {
        base.UseSkill(user, mainTarget);
        CurrentUser       = user;
        CurrentMainTarget = mainTarget;

        List <BJCreatureObject> ourCreatureObjects = (CurrentUser.Creature.Allegiance == Allegiance.Player) ? BJGameController.Instance.PlayerCreatureObjects : BJGameController.Instance.EnemyCreatureObjects;
        List <BJCreatureObject> secondaryTargets   = new List <BJCreatureObject> ();

        foreach (var creatureObject in ourCreatureObjects)
        {
            if (creatureObject != user && TargetPriorities.ContainsKey(ourCreatureObjects.IndexOf(creatureObject)) && creatureObject.Creature.HP > 0)
            {
                secondaryTargets.Add(creatureObject);
            }
        }

        foreach (var secondaryTarget in secondaryTargets)
        {
            foreach (var skill in secondaryTarget.Skills)
            {
                if (!skill.IsPassive)
                {
                    skill.CurrentCooldown = Mathf.Max(0, skill.CurrentCooldown - 1);
                }
            }
        }
        StartCoroutine(FinishSkill(0.1f));
    }
Example #7
0
 public void Attack(BJCreatureObject enemyCreature)
 {
     if (!IsAttacking)
     {
         IsAttacking = true;
         UseSkill(enemyCreature, CurrentSkill);
     }
 }
Example #8
0
 public override void UseSkill(BJCreatureObject user, BJCreatureObject mainTarget)
 {
     base.UseSkill(user, mainTarget);
     CurrentUser                   = user;
     CurrentMainTarget             = mainTarget;
     Projectile                    = Instantiate(ProjectilePrefab) as GameObject;
     shouldMoveProjectile          = true;
     Projectile.transform.position = new Vector3(CurrentUser.transform.position.x, CurrentUser.transform.position.y, initialZ);
 }
Example #9
0
    // public BJEffect AggroEffect;

    public override void UseSkill(BJCreatureObject user, BJCreatureObject mainTarget)
    {
        base.UseSkill(user, mainTarget);
        CurrentUser         = user;
        CurrentMainTarget   = mainTarget;
        Effects [0].Applier = user;
        mainTarget.ApplyEffect(Effects [0], true);
        StartCoroutine(FinishSkill(0.1f));
    }
Example #10
0
    public override void UseSkill(BJCreatureObject user, BJCreatureObject mainTarget)
    {
        base.UseSkill(user, mainTarget);
        moveCounter       = 0;
        CurrentUser       = user;
        CurrentMainTarget = mainTarget;
        float xCoord = (user.Creature.Allegiance == Allegiance.Player) ? 0.5f : -0.5f;

        user.MoveToPoint(mainTarget.transform.position - new Vector3(xCoord, 0.0f, 0.0f));
    }
Example #11
0
    // public BJEffect ArmorBuffEffect;

    public override void UseSkill(BJCreatureObject user, BJCreatureObject mainTarget)
    {
        base.UseSkill(user, mainTarget);
        CurrentUser       = user;
        CurrentMainTarget = mainTarget;

        mainTarget.Creature.Heal(Damage);

        StartCoroutine(FinishSkill(0.1f));
    }
Example #12
0
    IEnumerator EnemyAttack(float delay, BJCreatureObject creatureObject)
    {
        yield return(new WaitForSeconds(delay));

        if (CurrentCreatureObject.Creature.Allegiance == Allegiance.Player)
        {
            Debug.Log("WHAT THE F**K");
        }
        CurrentCreatureObject.Attack(creatureObject);
        CurrentCreatureObject.Deanimate();
    }
Example #13
0
    public void SpawnPlayerCreatures()
    {
        List <CreatureData> creatureDatas = Player.Instance.CurrentTeam;

        for (int i = 0; i < creatureDatas.Count; i++)
        {
            BJCreatureObject bjCreatureObject = SpawnCreatureObject(creatureDatas [i].Creature, creatureDatas [i].Level);
            bjCreatureObject.gameObject.transform.SetParent(PlayerSpawnPoints [i]);
            bjCreatureObject.gameObject.transform.localScale    = Vector3.one;
            bjCreatureObject.gameObject.transform.localPosition = Vector3.zero;
        }
    }
Example #14
0
 public override void User_OnCreatureMovementFinished(BJCreatureObject creatureObject)
 {
     base.User_OnCreatureMovementFinished(creatureObject);
     if (creatureObject.CurrentSkill != this)           // whoops :(
     {
         return;
     }
     if (shouldHit)
     {
         moveCounter++;
     }
     if (moveCounter < HitsAmount)
     {
         float xCoord = (CurrentUser.Creature.Allegiance == Allegiance.Player) ? 0.5f : -0.5f;
         if (shouldHit)
         {
             CurrentUser.DealDamage((int)(CurrentUser.Creature.BaseDamage * DamageMultiplier), 1.0f, CurrentMainTarget);
             for (int i = 0; i < Effects.Count; i++)
             {
                 if (Random.Range(0.0f, 0.99f) < EffectChances [i])
                 {
                     Effects [i].Applier = CurrentUser;
                     CurrentMainTarget.ApplyEffect(Effects [i], true);
                 }
             }
             CurrentUser.MoveToPoint(CurrentMainTarget.transform.position - new Vector3(xCoord, 0.0f, 0.0f));
             shouldHit = false;
         }
         else
         {
             CurrentUser.MoveToPoint(CurrentMainTarget.transform.position - new Vector3(xCoord * 2, 0.0f, 0.0f));
             shouldHit = true;
         }
     }
     if (moveCounter == HitsAmount)
     {
         CurrentUser.DealDamage((int)(CurrentUser.Creature.BaseDamage * DamageMultiplier), 1.0f, CurrentMainTarget);
         for (int i = 0; i < Effects.Count; i++)
         {
             if (Random.Range(0.0f, 0.99f) < EffectChances [i])
             {
                 Effects [i].Applier = CurrentUser;
                 CurrentMainTarget.ApplyEffect(Effects [i], true);
             }
         }
         CurrentUser.MoveToPoint(CurrentUser.InitialPosition);
     }
     if (moveCounter > HitsAmount)
     {
         StartCoroutine(FinishSkill(0.1f));
     }
 }
Example #15
0
    void BjCreatureObject_OnCreatureObjectClicked(BJCreatureObject creatureObject)        // non-player can't click
    {
        List <BJCreatureObject> targetCreatureObjects = (CurrentCreatureObject.CurrentSkill.TargetTeam == Teams.AnotherTeam) ? BJGameController.Instance.EnemyCreatureObjects : BJGameController.Instance.PlayerCreatureObjects;

        if (CurrentCreatureObject != null && CurrentCreatureObject.Creature.Allegiance == Allegiance.Player)           // && CurrentCreatureObject.CurrentSkill.TargetTeam == Teams.AnotherTeam) {
        {
            if (!CurrentCreatureObject.CurrentSkill.ValidTargetIndexes.Contains(targetCreatureObjects.IndexOf(creatureObject)))
            {
                return;
            }
            CurrentCreatureObject.Attack(creatureObject);
            CurrentCreatureObject.Deanimate();
        }
    }
Example #16
0
 void BjCreatureObject_OnCreatureTurnFinished(BJCreatureObject creatureObject)
 {
     CheckDead();
     foreach (var enemyCreatureObject in EnemyCreatureObjects)
     {
         enemyCreatureObject.SelectionCircle.gameObject.SetActive(false);
     }
     foreach (var playerCreatureObject in PlayerCreatureObjects)
     {
         playerCreatureObject.SelectionCircle.gameObject.SetActive(false);
     }
     if (CurrentCreatureObject == creatureObject)
     {
         Invoke("StartTurn", 0.25f);
     }
 }
Example #17
0
    void StartTurn()
    {
        CheckDead();
        if (TurnQueue.Count == 0)
        {
            FormQueue();
        }
        CurrentCreatureObject = TurnQueue.Dequeue();
        if (CurrentCreatureObject != null && CurrentCreatureObject.Creature.HP <= 0)
        {
            StartTurn();
            return;
        }
        CurrentCreatureChooseSkill(0);

        CurrentCreatureObject.GetReadyForTurn();
    }
Example #18
0
    public void DealDamage(int damage, float multiplier, BJCreatureObject enemy)
    {
        foreach (var effect in enemy.Effects)
        {
            if (effect is BJDelayDamageEffect)
            {
                (effect as BJDelayDamageEffect).DelayedDamage += damage;
                return;
            }

            if (effect is BJAdjustmentFireEffect && effect.Applier == this)
            {
                damage += effect.Damage;
            }
        }
        Creature.DealDamage(damage, multiplier, enemy.Creature);
    }
Example #19
0
    public override void User_OnCreatureMovementFinished(BJCreatureObject creatureObject)
    {
        base.User_OnCreatureMovementFinished(creatureObject);
        if (creatureObject.CurrentSkill != this)           // whoops :(
        {
            return;
        }

        moveCounter++;
        if (moveCounter == 1)
        {
            CurrentUser.DealDamage((int)CurrentUser.Creature.BaseDamage, 1.0f, CurrentMainTarget);
            CurrentUser.MoveToPoint(CurrentUser.InitialPosition);
        }
        if (moveCounter == 2)
        {
            StartCoroutine(FinishSkill(0.1f));
        }
    }
Example #20
0
    public void ReformQueue(BJCreatureObject injectedCreatureObject)
    {
        List <BJCreatureObject> allCreaturesList = new List <BJCreatureObject> ();

        foreach (var creatureObject in TurnQueue)
        {
            if (creatureObject.Creature.HP > 0)
            {
                allCreaturesList.Add(creatureObject);
            }
        }
        if (injectedCreatureObject != null)
        {
            allCreaturesList.Add(injectedCreatureObject);
        }

        allCreaturesList.Sort((x, y) =>
                              y.Creature.Speed.CompareTo(x.Creature.Speed));

        TurnQueue = new Queue <BJCreatureObject> (allCreaturesList);
    }
Example #21
0
    public override void UseSkill(BJCreatureObject user, BJCreatureObject mainTarget)
    {
        base.UseSkill(user, mainTarget);
        CurrentUser       = user;
        CurrentMainTarget = mainTarget;

        List <BJCreatureObject> enemyCreatureObjects = (CurrentUser.Creature.Allegiance == Allegiance.Player) ? BJGameController.Instance.EnemyCreatureObjects : BJGameController.Instance.PlayerCreatureObjects;

        CurrentSecondaryTargets = new List <BJCreatureObject> ();

        foreach (var creatureObject in enemyCreatureObjects)
        {
            if (creatureObject.Creature.HP > 0)
            {
                CurrentSecondaryTargets.Add(creatureObject);
            }
        }

        Utility.Shuffle(CurrentSecondaryTargets);

        Projectile                    = Instantiate(ProjectilePrefab) as GameObject;
        shouldMoveProjectile          = true;
        Projectile.transform.position = new Vector3(CurrentUser.transform.position.x, CurrentUser.transform.position.y, initialZ);
    }
Example #22
0
 public void UseSkill(BJCreatureObject target, BJSkill skill)
 {
     skill.UseSkill(this, target);
 }
Example #23
0
 public virtual void UseSkill(BJCreatureObject user, BJCreatureObject mainTarget)
 {
     CurrentCooldown = Cooldown;
 }
Example #24
0
    void BjCreatureObject_OnCreatureReadyForTurn(BJCreatureObject creatureObject)
    {
        CurrentCreatureObject.StartTurn();

        for (int i = 0; i < SkillButtons.Count; i++)
        {
            BJSkillButton skillButton = SkillButtons [i].GetComponent <BJSkillButton> ();
            skillButton.ReadyParticlesObject.SetActive(false);
            if (i >= CurrentCreatureObject.Skills.Count - 1)
            {
                SkillButtons [i].interactable       = false;
                skillButton.CooldownSlider.maxValue = 0;
                skillButton.CooldownSlider.value    = 0;
                skillButton.CooldownLabel.gameObject.SetActive(false);
            }
            else if (CurrentCreatureObject.Skills [i + 1].IsPassive)
            {
                SkillButtons [i].interactable       = false;
                skillButton.CooldownSlider.maxValue = 0;
                skillButton.ButtonImage.sprite      = CurrentCreatureObject.Skills [i + 1].SkillIcon;
                skillButton.CooldownSlider.value    = 0;
                skillButton.CooldownLabel.gameObject.SetActive(false);
            }
            else
            {
                SkillButtons [i].interactable       = true;
                skillButton.ButtonImage.sprite      = CurrentCreatureObject.Skills [i + 1].SkillIcon;
                skillButton.CooldownSlider.maxValue = CurrentCreatureObject.Skills [i + 1].Cooldown;
                skillButton.CooldownSlider.value    = CurrentCreatureObject.Skills [i + 1].CurrentCooldown;
                if (CurrentCreatureObject.Skills [i + 1].CurrentCooldown > 0)
                {
                    skillButton.CooldownLabel.gameObject.SetActive(true);
                    skillButton.CooldownLabel.text = CurrentCreatureObject.Skills [i + 1].CurrentCooldown + "";
                }
                else
                {
                    skillButton.ReadyParticlesObject.SetActive(true);
                    skillButton.CooldownLabel.gameObject.SetActive(false);
                }
            }
        }

        if (CurrentCreatureObject != null && CurrentCreatureObject.Creature.Allegiance == Allegiance.Enemy && PlayerCreatureObjects.Count > 0)
        {
            CheckDead();
            int index        = 0;
            int indexOfIndex = 0;
            do
            {
                indexOfIndex = Random.Range(0, CurrentCreatureObject.CurrentSkill.ValidTargetIndexes.Count);
                index        = CurrentCreatureObject.CurrentSkill.ValidTargetIndexes[indexOfIndex];
            } while (PlayerCreatureObjects.Count <= index || PlayerCreatureObjects[index].Creature.HP <= 0);
            foreach (var playerCreatureObject in PlayerCreatureObjects)
            {
                foreach (var effect in playerCreatureObject.Effects)
                {
                    if (playerCreatureObject.Creature.HP > 0 && effect is BJAggroEffect)
                    {
                        index = PlayerCreatureObjects.IndexOf(playerCreatureObject);
                    }
                }
            }
            StartCoroutine(EnemyAttack(0.25f, PlayerCreatureObjects[index]));
        }
    }