Ejemplo n.º 1
0
 public virtual void Attack(PawnBehaviour target)
 {
     if (EquipedWeapon != null)
     {
         EquipedWeapon.Attack(this, target);
     }
 }
    private void ControllPawn()
    {
        RaycastHit hitInfo = new RaycastHit();
        bool       hit     = Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hitInfo);

        if (hitInfo.transform.gameObject.tag == "Ground")
        {
            Ray   ray      = Camera.main.ScreenPointToRay(Input.mousePosition);
            Plane hPlane   = new Plane(Vector3.up, Vector3.zero);
            float distance = 0;
            if (hPlane.Raycast(ray, out distance))
            {
                GameObject go2 = Field.getClosestTile(ray.GetPoint(distance));
                if (go2 != null)
                {
                    PawnBehaviour pb = gameObjectClicked.GetComponent <PawnBehaviour>();
                    pb.MoveOnTile(go2);
                }
            }
        }
        else if (hitInfo.transform.gameObject.tag == "Pawn")
        {
            gameObjectClicked = hitInfo.transform.gameObject;
        }
    }
Ejemplo n.º 3
0
 public override void Attack(PawnBehaviour target)
 {
     if (EquipedWeapon != null)
     {
         EquipedWeapon.PlayerAttack(this, attackAngle);
     }
 }
Ejemplo n.º 4
0
 public void PlayerAttack(PawnBehaviour owner, float angle)
 {
     if (timeToNextAttack <= 0)
     {
         Collider2D[] colliders = Physics2D.OverlapCircleAll(owner.transform.position, weaponStats.RangeOfAttack);
         foreach (Collider2D collider in colliders)
         {
             if (collider.tag == owner.enemyTag)
             {
                 Vector2 vec      = collider.transform.position - owner.transform.position;
                 float   curAngle = Vector2.Angle(owner.transform.up, vec);
                 if (curAngle < angle / 2f)
                 {
                     PawnBehaviour temp = collider.GetComponent <PawnBehaviour>();
                     if (temp != null)
                     {
                         temp.TakeDamage(weaponStats.GetDamage, weaponStats.Effects);
                     }
                 }
                 print(collider.tag + ":" + LayerMask.LayerToName(collider.gameObject.layer) + ":" + angle);
             }
         }
         if (anim != null)
         {
             anim.SetBool("isAttacking", true);
             isAttacking = true;
         }
         timeToNextAttack = weaponStats.TimeBetweenAttack;
     }
 }
Ejemplo n.º 5
0
    public void Equip()
    {
        PawnBehaviour owner = currentSlot.containerUI.inventory.GetComponent <PawnBehaviour>();

        if (owner != null)
        {
            currentSlot.containerUI.inventory.GetComponent <PawnBehaviour>().Equip(item);
            UnSubcribeActions();
        }
    }
Ejemplo n.º 6
0
 public void Init(FSM fsm, PawnBehaviour owner)
 {
     this.fsm = fsm;
     fsm.PushState(Patrol);
     player     = GameObject.FindGameObjectWithTag("Player").GetComponent <PawnBehaviour>();
     this.owner = owner;
     fov.Init(owner);
     fov.OnFindPlayer += FindPlayer;
     fov.OnLosePlayer += LosePlayer;
     curentPatrolIndex = 0;
 }
Ejemplo n.º 7
0
 public virtual void Attack(PawnBehaviour owner, PawnBehaviour target)
 {
     if (timeToNextAttack <= 0 && Vector2.Distance(owner.transform.position, target.transform.position) < weaponStats.RangeOfAttack)
     {
         target.TakeDamage(weaponStats.GetDamage, weaponStats.Effects);
         if (anim != null)
         {
             anim.SetBool("isAttacking", true);
             isAttacking = true;
         }
         timeToNextAttack = weaponStats.TimeBetweenAttack;
     }
 }
Ejemplo n.º 8
0
    void damageEnemy(Transform enemy)
    {
        PawnBehaviour tempEnemy = enemy.GetComponent <PawnBehaviour>();

        if (tempEnemy != null)
        {
            if (missileRadius > 0f)
            {
                tempEnemy.takeDamage(missileDamageAmount);
            }
            else
            {
                tempEnemy.takeDamage(turretDamageAmount);
            }
        }
        //Destroy(enemy.gameObject);
    }
Ejemplo n.º 9
0
    public EnemyFSM(FSM fsm, PawnBehaviour owner)
    {
        this.fsm = fsm;
        fsm.PushState(Patrol);
        player            = GameObject.FindGameObjectWithTag("Player").GetComponent <PawnBehaviour>();
        this.owner        = owner;
        fov               = new FielOfView(owner);
        fov.OnFindPlayer += FindPlayer;
        fov.OnLosePlayer += LosePlayer;
        curentPatrolIndex = 0;
        fsm.StartCoroutine(fov.Find());

        patrolPoints.Add(new Vector2(-17, 7));
        patrolPoints.Add(new Vector2(5, 18));
        patrolPoints.Add(new Vector2(16, -10));
        patrolPoints.Add(new Vector2(-15, -11));
    }
Ejemplo n.º 10
0
 public void Init(PawnBehaviour owner)
 {
     this.owner = owner;
     player     = GameObject.FindGameObjectWithTag("Player").GetComponent <PawnBehaviour>();
     owner.StartCoroutine(Find());
 }
Ejemplo n.º 11
0
    IEnumerator FindInventory()
    {
        UIManager.instance.OnPressInteractionButton += Interact;
        while (true)
        {
            yield return(new WaitForSecondsRealtime(0.2f));

            if (inInteraction)
            {
                if (!new List <Collider2D>(Physics2D.OverlapCircleAll(transform.position, SearchRadius)).Contains(findedInventory.GetComponent <Collider2D>()))
                {
                    findedInventory = null;
                    UIManager.instance.HideUIInventory();
                    inInteraction = false;
                }
            }
            else
            {
                findedItem      = null;
                findedInventory = null;
                findedDoor      = null;
                Collider2D[] things  = Physics2D.OverlapCircleAll(transform.position, SearchRadius);
                float        minDist = float.MaxValue;
                Collider2D   col     = null;
                for (int i = 0; i < things.Length; i++)
                {
                    Inventory   inv  = things[i].GetComponent <Inventory>();
                    DungeonDoor door = things[i].GetComponent <DungeonDoor>();

                    if (inv == null && things[i].GetComponent <Item>() == null && door == null)
                    {
                        continue;
                    }

                    if (door != null)
                    {
                        findedDoor = door;
                    }

                    if (inv != null)
                    {
                        PawnBehaviour pawn = inv.GetComponent <PawnBehaviour>();
                        if (pawn != null)
                        {
                            if (pawn == this || !pawn.IsDead)
                            {
                                continue;
                            }
                        }
                    }

                    float dist = Vector2.Distance(this.transform.position, things[i].transform.position);

                    if (dist < minDist)
                    {
                        minDist = dist;
                        col     = things[i];
                    }
                }

                if (col != null)
                {
                    findedInventory = col.GetComponent <Inventory>();
                    findedItem      = col.GetComponent <Item>();
                }

                if (findedInventory != null)
                {
                    UIManager.instance.ShowTextInfo("Press E to Loot");
                }
                else if (findedItem != null)
                {
                    UIManager.instance.ShowTextInfo("Press E to pick Up " + findedItem.itemName);
                }
                else if (findedDoor != null)
                {
                    UIManager.instance.ShowTextInfo(findedDoor.IsEnter ? "Press E to enter previous dungeon" : "Press E to enter next dungeon");
                }
                else
                {
                    UIManager.instance.HideTextInfo();
                }
            }
        }
    }