Ejemplo n.º 1
0
    public GameContext GetContextForPlayer(ControlledActor player)
    {
        var context = new GameContext();

        context.ElapsedTime = ElapsedGameTime;
        context.RemainTime  = RemainGameTime;
        var enemies     = new List <ActorInfo>();
        var projectiles = new List <ProjectileInfo>();
        var bonuses     = new List <BonusInfo>();

        foreach (var actor in playersActors)
        {
            if (actor != player)
            {
                enemies.Add(actor.Info);
            }
        }
        foreach (var proj in _projectiles)
        {
            projectiles.Add(proj.GetInfo());
        }
        foreach (var bonus in _bonuses)
        {
            bonuses.Add(bonus.GetInfo());
        }
        context.SetEnemies(enemies);
        context.SetProjectiles(projectiles);
        context.SetBonuses(bonuses);
        context.SetBorders(_left, _right, _up, _down);
        context.RemainTime  = RemainGameTime;
        context.ElapsedTime = ElapsedGameTime;

        return(context);
    }
Ejemplo n.º 2
0
 public void Initialize(ControlledActor owner)
 {
     _spawnTime        = Time.time;
     _owner            = owner;
     _spriteRend.color = owner.GetColor();
     _rb.velocity      = owner.GetForwardVector().normalized *GameController.Instance.GameConfig.ProjectileVelocity;
 }
Ejemplo n.º 3
0
 public void SetActor(ControlledActor actor)
 {
     _actor = actor;
     transform.SetSiblingIndex(1000000 - actor.Score);
     _background.color = actor.GetColor();
     _actorName.text   = actor.Info.name;
     _actorScore.text  = actor.Score.ToString();
 }
Ejemplo n.º 4
0
    private IEnumerator KillActorRoutine(ControlledActor actor)
    {
        playersActors.Remove(actor);
        actor.gameObject.SetActive(false);
        yield return(new WaitForSeconds(GameConfig.RespawnTime));

        actor.transform.position = _spawnPositions[Random.Range(0, _spawnPositions.Count)].position;
        actor.Heal(GameConfig.MaxHealth);
        actor.gameObject.SetActive(true);
        playersActors.Add(actor);
    }
Ejemplo n.º 5
0
 /// <summary>
 /// Crée la bombe depuis son lanceur, et indique à sa collision de déclencher l'explosion lorsque la collision
 /// se déclenche avec un objet tangible.
 /// </summary>
 /// <param name="owner"> Celui qui a lancé la bombe </param>
 /// <param name="target"> La cible de la bombe </param>
 public Bomb(ControlledActor owner, Point target) : base(owner, target, InitialSpeed, (double)Range / InitialSpeed)
 {
     _owner        = (LivingActor)owner;
     SpriteHandler = new AnimationHandler(this, Sprites.Bomb);
     SetCollision(new ActorCollision(this, Hitbox, HitboxType.Immaterial, actor =>
     {
         if (!FriendWith(actor) && actor.Collision.HitboxType != HitboxType.Immaterial)
         {
             Kill();
             Explodes();
         }
     }));
     ResiduData   = new ResiduData(this, AnimationType.Death, false);
     _hasExplosed = false;
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Crée le sort en lui assignant son joueur et les données indiquées.
 /// Le sort est crée avec une charge.
 /// La statistique de CooldownReduction du joueur réduit le temps de recharge du sort.
 /// </summary>
 /// <param name="owner"> Le possesseur du sort </param>
 /// <param name="spellData"> Les données du sort </param>
 /// <param name="stats"> Les statistiques du joueur </param>
 public Spell(ControlledActor owner, SpellData spellData, PlayerStats stats)
 {
     _owner     = owner;
     _spellData = spellData;
     StateData  = new StateData(_spellData.CastTimeMs, null, (actor, arg) =>
     {
         actor.UnlockCasts();
         if (!_spellData.CanMove)
         {
             actor.UnlockMoves();
         }
     });
     _currentMs = DefaultMs;
     _cooldown  = new BoundedDouble(_spellData.Cooldown * stats.CooldownRatio(), -1)
     {
         Value = 0
     };
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Crée l'état avec les données fournies et en l'associant à un acteur.
 /// </summary>
 /// <param name="owner"> L'acteur associé </param>
 /// <param name="data"> les données </param>
 /// <param name="arg"> Le paramètre optionnel </param>
 public State(ControlledActor owner, StateData data, object arg)
 {
     _owner = owner;
     _data  = data;
     _arg   = arg;
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Initialise le StateHandler.
 /// </summary>
 /// <param name="owner"> L'acteur associé aux effets </param>
 public StateHandler(ControlledActor owner)
 {
     _owner  = owner;
     _states = new List <State>();
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Initialise le Spellhandler sans sorts.
 /// </summary>
 /// <param name="owner"> Le possesseur des sorts </param>
 public SpellHandler(ControlledActor owner)
 {
     _owner  = owner;
     _spells = new Dictionary <int, Spell>();
 }
Ejemplo n.º 10
0
 public void KillActor(ControlledActor actor)
 {
     StartCoroutine(KillActorRoutine(actor));
 }
Ejemplo n.º 11
0
 public void Collect(ControlledActor actor)
 {
     actor.Heal(healValue);
     actor.AddScore(bonusScoreValue);
     Destroy(this.gameObject);
 }