コード例 #1
0
    public bool TryMove(Vector2 dir)
    {
        RaycastHit2D hit;

        //if (Player.Instance.GetState() == Player.PlayerState.Ghosting) return true;

        bool canMove = CanMove(out hit, dir); // base.CanMove(out hit); <- should be apart of movement class to check if can move using the raycast toward player movement

        ReactiveEntity Interactable = null;

        if (!canMove)
        {
            Interactable = hit.transform.GetComponent <ReactiveEntity>();
        }

        if (Interactable != null)
        {
            OnCantMove(Interactable);
        }

        Player.Instance.Check();

        GameManager.Instance.PlayersTurn = false; // this is how gamemanager should be called because it is a singleton you do not need to keep reference there is only one,
                                                  // look into singleton design pattrn, anything there is only one of should follow this pattern (player maybe should do this).
        return(canMove);
    }
コード例 #2
0
    public bool TryMove(Vector2 dir)
    {
        RaycastHit2D hit;

        bool canMove = CanMove(out hit, dir); // base.CanMove(out hit); <- should be apart of movement class to check if can move using the raycast toward player movement

        ReactiveEntity Interactable = null;
        Player         Player       = null;

        if (!canMove)
        {
            Interactable = hit.transform.GetComponent <ReactiveEntity>();
        }
        if (!canMove)
        {
            Player = hit.transform.GetComponent <Player>();
        }

        if (Interactable != null)
        {
            OnCantMove(Interactable);
        }
        else if (Player != null && Player.Instance.GetState() != Player.PlayerState.Ghosting)
        {
            OnCantMove(Player);
        }

        return(canMove);
    }
コード例 #3
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        ReactiveEntity interactable = collision.gameObject.GetComponent <ReactiveEntity>();

        if (interactable != null)
        {
            collision.gameObject.GetComponent <ReactiveEntity>().Interact <Player>(this);
        }
    }
コード例 #4
0
        /// <summary>
        /// Applies the specified <paramref name="mitigation"/> for the specified <paramref name="entity"/>.
        /// </summary>
        /// <param name="entity">The entity for which a mitigation is applied.</param>
        /// <param name="mitigation">The mitigation to apply.</param>
        /// <returns>true if a mitigation was applied; otherwise, false.</returns>
        public bool DoMitigate(ReactiveEntity entity, ReactiveEntityRecoveryFailureMitigation mitigation)
        {
            OnAll(entity);

            return(mitigation switch
            {
                ReactiveEntityRecoveryFailureMitigation.Ignore => OnIgnore(entity),
                ReactiveEntityRecoveryFailureMitigation.Remove => OnRemove(entity),
                ReactiveEntityRecoveryFailureMitigation.Regenerate => OnRegenerate(entity),
                _ => false,
            });
コード例 #5
0
 public override void Interact<T>(T component)
 {
     ReactiveEntity interactable = component.GetComponent<ReactiveEntity>();
     if (interactable != null)
     {
         Player pl = interactable.GetComponent<Player>();
         if (pl != null)
         {
             //Debug.Log(pl.gameObject.name + " attacking " + gameObject.name);
             pl.Attack(this);
         }
     }
 }
コード例 #6
0
    public void OnCantMove <T>(T component) where T : Component
    {
        if (Player.Instance.GetState() == Player.PlayerState.Ghosting && !component.transform.GetComponent <Statue>())
        {
            return;
        }
        ReactiveEntity interactable = component.GetComponent <ReactiveEntity>();

        if (interactable != null && GetComponent <Player>())
        {
            // interact with interactable
            Debug.Log(transform.gameObject.name + " interacting with: " + interactable.transform.gameObject.name);
            interactable.Interact <ReactiveEntity>(GetComponent <Player>());
        }
    }
コード例 #7
0
 public void Attack(ReactiveEntity actor)
 {
     //Debug.Log("trying to attack player");
     //set up to where they can also attack npc's
     SetState(ActionState.Attacking);
     if (actor.GetComponent<Player>())
     {
         Player.Instance.Defense(this.enemyStats.damage, gameObject.name);
     }
     else
     {
         NPC enemy = actor.GetComponent<NPC>();
         if (enemy != null)
         {
             enemy.Defense(this.enemyStats.damage, gameObject.name);
         }
     }
 }
コード例 #8
0
    public void OnCantMove <T>(T component) where T : Component
    {
        ReactiveEntity interactable = component.GetComponent <ReactiveEntity>();

        if (interactable != null)
        {
            // interact with interactable Have to decide if npcs can interact with stuff
            //interactable.Interact<Player>(Player.Instance);
            //Debug.Log(transform.gameObject.name + " interacting with: " + interactable.transform.gameObject.name);

            if ((interactable.CompareTag("Player") || interactable.CompareTag("NPC")) && GetComponent <NPC>())
            {
                // do stuff with enemy (if running into player, enemy is prolly trying to attack player so maybe do something like:
                Debug.Log(transform.gameObject.name + " interacting with: " + interactable.transform.gameObject.name);
                interactable.Interact(GetComponent <NPC>());
            }
        }
    }
コード例 #9
0
 /// <summary>
 /// Called upon applying a <see cref="ReactiveEntityRecoveryFailureMitigation.Regenerate"/> mitigation.
 /// </summary>
 /// <param name="entity">The entity for which a mitigation is applied.</param>
 /// <returns>true if the mitigation was applied; otherwise, false.</returns>
 protected virtual bool OnRegenerate(ReactiveEntity entity) => false;
コード例 #10
0
 /// <summary>
 /// Called upon applying a <see cref="ReactiveEntityRecoveryFailureMitigation.Remove"/> mitigation.
 /// </summary>
 /// <param name="entity">The entity for which a mitigation is applied.</param>
 /// <returns>true if the mitigation was applied; otherwise, false.</returns>
 protected virtual bool OnRemove(ReactiveEntity entity) => false;
コード例 #11
0
 /// <summary>
 /// Called upon applying an <see cref="ReactiveEntityRecoveryFailureMitigation.Ignore"/> mitigation.
 /// </summary>
 /// <param name="entity">The entity for which a mitigation is applied.</param>
 /// <returns>true if the mitigation was applied; otherwise, false.</returns>
 protected virtual bool OnIgnore(ReactiveEntity entity) => true;
コード例 #12
0
 /// <summary>
 /// Called for every type of mitigation. Allows the derived class to run some actions before performing the mitigation.
 /// </summary>
 /// <param name="entity">The entity for which a mitigation is applied.</param>
 protected virtual void OnAll(ReactiveEntity entity)
 {
 }