Esempio n. 1
0
    public void onNotify(IGameActor actor, Event ev)
    {
        switch (ev)
        {
        case Event.EVENT_ACTOR_MOVE:
            isMoving = true;
            break;

        case Event.EVENT_ACTOR_STOP:
            isMoving = false;
            break;

        case Event.EVENT_ACTOR_ATTACK:
            animator_.SetTrigger("attack");
            isAttacking = true;
            break;

        case Event.EVENT_ACTOR_HEAL_BUFF:
            animator_.SetTrigger("heal");
            isHealing = true;
            break;

        case Event.EVENT_ACTOR_TAKE_DAMAGE:
            animator_.SetTrigger("hurt");
            isHurting = true;
            break;
        }
    }
Esempio n. 2
0
    public void attack()
    {
        int     lookingSide     = facingRight_ ? 1 : -1;
        Vector2 correctedOffset = attackColliderOffset_;

        correctedOffset.x *= lookingSide;

        Vector2 origin = (Vector2)transform.position + correctedOffset;

        var hit = Physics2D.BoxCast(origin, attackColliderSize_, 0f, Vector2.zero, Mathf.Infinity, attackMask_);

        if (hit.collider == null)
        {
            return;
        }
        GameObject player      = hit.collider.gameObject;
        IGameActor playerActor = player.GetComponent <IGameActor>();

        #if UNITY_EDITOR
        if (playerActor == null)
        {
            Error.ShowError("Object with \"Player\" tag does not have a IGameActor script");
        }
        #endif

        playerActor.takeDamage(1);

        notify(this, Event.EVENT_ACTOR_ATTACK);
    }
Esempio n. 3
0
    void Start()
    {
        playerActions_ = GetComponent <PlayerActions>();

        zKey_     = new AttackCommand(playerActions_);
        xKey_     = new BuffCommand(playerActions_, Buff.BUFF_HEAL);
        spaceKey_ = new InteractCommand(playerActions_);
    }
 public void useBuff(IGameActor actor, Buff buff)
 {
     if (!canAct)
     {
         return;
     }
     notify(null, Event.EVENT_ACTOR_HEAL_BUFF);
     canAct = false;
 }
Esempio n. 5
0
 public void onNotify(IGameActor actor, Event ev)
 {
     switch (ev)
     {
     case Event.EVENT_ACTOR_TAKE_DAMAGE_ANIM_ENDED:
         isHurting = false;
         break;
     }
 }
    private IGameActor GetGameActor(RaycastHit2D hit)
    {
        IGameActor enemy = hit.collider.gameObject.GetComponent <IGameActor>();

        #if UNITY_EDITOR
        if (enemy == null)
        {
            Error.ShowError("Object with \"Enemy\" tag does not have a IGameActor script");
        }
        #endif
        return(enemy);
    }
Esempio n. 7
0
 public void AddHitToActor(IGameActor touchedActor)
 {
     if (touchedActor != null)
     {
         if (!actorsHitbyProjectile.ContainsKey(MyId))
         {
             actorsHitbyProjectile[MyId] = new List <IGameActor>();
         }
         if (!actorsHitbyProjectile[MyId].Contains(touchedActor))
         {
             actorsHitbyProjectile[MyId].Add(touchedActor);
         }
         RemainingHits--;
     }
 }
Esempio n. 8
0
        public void AddActor(IGameActor Actor)
        {
            lock (this.myActors)
                this.myActors.Add(Actor.ActorId, Actor);

            // on affecte la cell
            Actor.CellId = this.Id;

            if (Actor.ActorType == GameActorTypeEnum.TYPE_CHARACTER)
            {
                foreach (var Action in this.myActions)
                {
                    Action.Apply(Actor as Player);
                }
            }
        }
Esempio n. 9
0
    public void onNotify(IGameActor actor, Event ev)
    {
        switch (ev)
        {
        case Event.EVENT_ACTOR_ANIM_PLAYING:
            canAct_ = false;
            break;

        case Event.EVENT_ACTOR_ANIM_ENDED:
            canAct_ = true;
            break;

        case Event.EVENT_ACTOR_LOW_HEALTH:
            lowHealth_ = true;
            break;
        }
    }
Esempio n. 10
0
    void Start()
    {
        slimeActor_ = GetComponent <IGameActor>();
        SlimeActions actions = GetComponent <SlimeActions>();

        actions.addObserver(this);
        SlimeAnimation anim = GetComponent <SlimeAnimation>();

        anim.addObserver(this);

        player_ = GameObject.FindGameObjectWithTag("Player").transform;

        stateScore_ = new Dictionary <SlimeState, int>();
        foreach (SlimeState state in Enum.GetValues(typeof(SlimeState)))
        {
            stateScore_.Add(state, 0);
        }
    }
Esempio n. 11
0
    public bool CanHitActor(IGameActor touchedActor)
    {
        bool canHitActor = true;

        if (touchedActor == null)
        {
            canHitActor = false;
        }
        else if (touchedActor.IsDodging())
        {
            canHitActor = false;
        }
        else if (MyOwner != null && touchedActor.GetTribe() == MyOwner.GetTribe())
        {
            canHitActor = false;
        }
        else if (actorsHitbyProjectile.TryGetValue(MyId, out List <IGameActor> actors) &&
                 actors.Contains(touchedActor))
        {
            // Don't let a bullet hit the same character multiple times.
            canHitActor = false;
        }
        return(canHitActor);
    }
Esempio n. 12
0
 private void Initialize(WeaponDefinition weapon, IGameActor owner, uint projectileId)
 {
     MyWeaponData      = weapon;
     MyOwner           = owner;
     RemainingLifetime = weapon.lifetime;
     RemainingHits     = weapon.maximumEnemiesHit;
     MyId = projectileId;
     if (weapon.projectileLockedEffect != null)
     {
         spawnedEffect = CosmeticEffect.Spawn(weapon.projectileLockedEffect, weapon.lifetime, transform.position, transform.rotation, this.transform);
         dummyRenderer.SetActive(false);
     }
     else
     {
         dummyRenderer.SetActive(!weapon.hiddenAttack);
     }
     // Don't spawn the actorsHitByProjectile array until it actually hits something.
     if (weapon.reflectsOtherAttacks)
     {
         reflectionCollider.gameObject.SetActive(true);
         reflectionCollider.radius = weapon.radius;
         reflectingColliders[reflectionCollider] = MyOwner;
     }
 }
Esempio n. 13
0
 public GameActorShowMessage(GameActorShowEnum ShowType, IGameActor Actor)
 {
     this.Actor    = Actor;
     this.ShowType = ShowType;
 }