Esempio n. 1
0
    private void SpawnNewProjectiles(BattleMoveOutputSingle[] results)
    {
        foreach (var result in results)
        {
            if (result.ProjVelosity != null)
            {
                UnitData unit = this.units.Single(x => x.ID == result.ID);

                SpellCooldown spellCD = unit.SpellCooldowns.FirstOrDefault(x => x.Spell == "fireball");

                if (spellCD.CurrentIteration <= 0)
                {
                    spellCD.CurrentIteration = spellCD.MaxIteration;

                    ProjectileData proj = new ProjectileData()
                    {
                        Demage           = 20,
                        Direction        = result.ProjVelosity.Value,
                        Position         = unit.Position,
                        Radious          = (Fix64)1f,
                        Team             = unit.Team,
                        Type             = result.ProjType,
                        CurrentIteration = 0,
                        MaxIteration     = this.projDuration,
                    };

                    this.projectiles.Add(proj);
                }
            }
        }
    }
 private void OnServerSpellCooldown(Player player, SpellCooldown cooldown)
 {
     if (player.BoltEntity.Controller != null)
     {
         SpellCooldownEvent spellCooldownEvent = SpellCooldownEvent.Create(player.BoltEntity.Controller, ReliabilityModes.ReliableOrdered);
         spellCooldownEvent.SpellId      = cooldown.SpellId;
         spellCooldownEvent.CooldownTime = cooldown.Cooldown;
         spellCooldownEvent.ServerFrame  = BoltNetwork.ServerFrame;
         spellCooldownEvent.Send();
     }
 }
Esempio n. 3
0
    //private PlayerController playerController;

    // Start is called before the first frame update
    void Start()
    {
        // Sets all for Chawa's UI
        _spellCooldownController = spellCooldown.GetComponent <SpellCooldown>();

        animator = GetComponent <Animator>();

        /*
         * if (unlockedSpells.Contains(spells.Fire))
         * {
         *  equipedSpell = spells.Fire;
         * }
         */
        player = GameObject.Find("Chawa");
        sfx    = GameObject.Find("SFX Controller").GetComponent <SFXController>();
    }
Esempio n. 4
0
    private void ProcessCooldowns(List <UnitData> units)
    {
        foreach (var unit in units)
        {
            List <SpellCooldown> cooldowns = unit.SpellCooldowns;

            for (int i = cooldowns.Count - 1; i >= 0; i--)
            {
                SpellCooldown cooldown = cooldowns[i];

                if (cooldown.CurrentIteration > 0)
                {
                    cooldown.CurrentIteration--;
                }
            }
        }
    }
Esempio n. 5
0
    public BattleMoveOutputSingle[] MakeMove(BattleMoveInputWholeTeam input)
    {
        var returnVal = new BattleMoveOutputSingle[input.FriendlyUnits.Length];
        MoveHelpersDeterministic help = new MoveHelpersDeterministic();

        BattleMoveOutputSingle[] result = input.FriendlyUnits.Select(x => new BattleMoveOutputSingle()).ToArray();

        for (int i = 0; i < input.FriendlyUnits.Length; i++)
        {
            UnitData      myUnit     = input.FriendlyUnits[i];
            Fix64Vector2  myLocation = input.FriendlyUnits[i].Position;
            SpellCooldown fireball   = myUnit.SpellCooldowns.FirstOrDefault(x => x.Spell == "fireball");
            result[i].ProjVelosity = null;
            if (fireball != null && input.EnemyUnits.Length > 0 && fireball.CurrentIteration <= 0)
            {
                result[i].ProjVelosity = input.EnemyUnits[0].Position - myLocation;
            }

            var allHits = input.EnemyProjs
                          .Select(x => new { one = help.DistanceToHit(x.Position, x.Direction, myLocation), two = x })
                          .Where(x => x.one != null)
                          .Where(x => x.one.HitVector.Magnitude <= (Fix64)1.5f)
                          .ToArray();

            result[i].NewLocation = null;
            if (allHits.Length != 0)
            {
                var          thing     = allHits.First(x => x.one.DistanceToProj == allHits.Min(y => y.one.DistanceToProj));
                Fix64Vector2 hitVector = thing.one.HitVector;
                Fix64Vector2 projVel   = thing.two.Direction;

                if (hitVector.Magnitude == (Fix64)0)
                {
                    result[i].NewLocation = (projVel.Negative()).Rotate((Fix64)90);
                }
                else
                {
                    result[i].NewLocation = (hitVector.Negative()).Normalized;
                }
            }
        }

        return(result);
    }