Beispiel #1
0
 void OnTriggerEnter2D(Collider2D a_object)
 {
     if (a_object.CompareTag("Player"))
     {
         m_trap.Activate();
     }
 }
    private void Update()
    {
        ControllerInputCheck();

        if (actionButtonPressed && selectedTrap != null)
        {
            selectedTrap.Activate();
        }
    }
Beispiel #3
0
    public override void DoAction(PlayerCharacter character, Selectable select)
    {
        Trap trap = select.GetComponent <Trap>();

        if (trap != null)
        {
            trap.Activate();
        }
    }
Beispiel #4
0
    public void ActivateTrap()
    {
        if (linkedTrap == null)
        {
            Debug.LogError("No trap assigned to this activator. Please assign a trap in the linked trap field!");
            return;
        }

        linkedTrap.Activate();
    }
Beispiel #5
0
 void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.tag == "Player")
     {
         Debug.Log("Trigger");
         bool res = trapToTrigger.Activate();
         if (res)
         {
             col.enabled = false;
         }
     }
 }
        public void Update(TimeSpan elapsedTime)
        {
            #region Sanity Checks

            if (Aisling == null)
            {
                return;
            }

            if (!Aisling.LoggedIn)
            {
                return;
            }

            if ((DateTime.UtcNow - Aisling.LastLogged).TotalMilliseconds < ServerContextBase.Config.LingerState)
            {
                return;
            }

            #endregion

            var distance = Aisling.Position.DistanceFrom(Aisling.LastPosition.X, Aisling.LastPosition.Y);

            if (distance > 2 && !IsWarping && (DateTime.UtcNow - LastMapUpdated).TotalMilliseconds > 2000)
            {
                LastWarp = DateTime.UtcNow;
                Aisling.LastPosition.X = (ushort)Aisling.XPos;
                Aisling.LastPosition.Y = (ushort)Aisling.YPos;
                LastLocationSent       = DateTime.UtcNow;
                Refresh();
                return;
            }

            if (Aisling.TrapsAreNearby())
            {
                var nextTrap = Trap.Traps.Select(i => i.Value)
                               .FirstOrDefault(i => i.Owner.Serial != Aisling.Serial &&
                                               Aisling.Map.Flags.HasFlag(MapFlags.PlayerKill) &&
                                               i.Location.X == Aisling.X && i.Location.Y == Aisling.Y);

                if (nextTrap != null)
                {
                    Trap.Activate(nextTrap, Aisling);
                }
            }

            DoUpdate(elapsedTime);
        }
Beispiel #7
0
 public void Update()
 {
     if (Input.GetMouseButtonDown(0))
     {
         Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
         RaycastHit hit;
         if (Physics.Raycast(ray, out hit))
         {
             Trap trap = hit.collider.GetComponentInParent <Trap>();
             if (trap != null)
             {
                 trap.Activate();
             }
         }
     }
 }
Beispiel #8
0
    private void FixedUpdate()
    {
        if (dropTrap)
        {
            print("DropTrap");
            if (trapInstance != null)
            {
                //trapInstance.gameObject.SetActive(true);
                SetCarrying(false);
                trapSet = true;
                trapInstance.transform.position = DropPos.transform.position;

                dropTrap = false;
            }
        }

        if (pickupTrap)
        {
            if (trapCloseTo != null)
            {
                trapInstance = trapCloseTo;
                //trapCloseTo.gameObject.SetActive(false);
                trapCloseTo = null;
                SetCarrying(true);
            }

            pickupTrap = false;
        }

        if (activateTrap)
        {
            trapInstance.Activate();
            trapSet = false;

            activateTrap = false;
        }

        if (baitTrap)
        {
            trapCloseTo.ShowBaitMenu();
            baitTrap = false;
            GetComponent <PlayerControl>().Stop();
            GetComponent <PlayerControl>().enabled = false;
        }
    }
        public void UpdateMonsterObjects(TimeSpan elapsedTime, IEnumerable <Monster> objects)
        {
            var enumerable = objects as Monster[] ?? objects.ToArray();

            foreach (var obj in enumerable)
            {
                if (obj?.Map == null || obj.Scripts == null)
                {
                    continue;
                }

                if (obj.CurrentHp <= 0x0 && obj.Target != null && !obj.Skulled)
                {
                    foreach (var script in obj.Scripts.Values.Where(script => obj.Target?.Client != null))
                    {
                        script?.OnDeath(obj.Target.Client);
                    }

                    obj.Skulled = true;
                }

                foreach (var script in obj.Scripts.Values)
                {
                    script?.Update(elapsedTime);
                }

                if (obj.TrapsAreNearby())
                {
                    var nextTrap = Trap.Traps.Select(i => i.Value)
                                   .FirstOrDefault(i => i.Location.X == obj.X && i.Location.Y == obj.Y);

                    if (nextTrap != null)
                    {
                        Trap.Activate(nextTrap, obj);
                    }
                }

                obj.UpdateBuffs(elapsedTime);
                obj.UpdateDebuffs(elapsedTime);
                obj.LastUpdated = DateTime.UtcNow;
            }
        }
Beispiel #10
0
 public void TrapActivated()
 {
     state = GameState.Trap;
     trap.Activate();
     serverListener.sendMessageToAllClients("trap:encountered");
 }
Beispiel #11
0
 public override bool DealWithTrap(Trap trap)
 {
     money -= trap.Activate();
     return(true);
 }
Beispiel #12
0
 private void OnTriggerEnter(Collider other)
 {
     trap.Activate();
 }
 void Start()
 {
     AssociatedTrap.Activate(isActive);
 }
Beispiel #14
0
    void LateUpdate()
    {
        hasObstacleTop   = Physics.Linecast(centerCheck.position, topCheck.position, out hitTop, 1 << 0);
        hasObstacleRight = Physics.Linecast(centerCheck.position, rightCheck.position, out hitRight, 1 << 0);
        hasObstacleLeft  = Physics.Linecast(centerCheck.position, leftCheck.position, out hitLeft, 1 << 0);

        hasObstacleBottom = Physics.Linecast(centerCheck.position, bottomCheck.position, out hitBottom, 1 << 0);

        bool colliding = false;

        if (hitBottom.collider != null)
        {
            Item item = hitBottom.collider.GetComponent <Item>();
            if (item)
            {
                if (item.itemType == ItemType.Trap && !pasUneVictime)
                {
                    Trap trap = (Trap)item;
                    trap.Activate(victime, victime.GetComponent <AudioSource>());
                }
                if (item.itemType == ItemType.Bonus && !pasUneVictime)
                {
                    Bonus bonus = (Bonus)item;
                    bonus.PickUpBonus(victime, victime.GetComponent <AudioSource>());
                }


                if (item.itemType == ItemType.Key && !pasUneVictime)
                {
                    Key key = (Key)item;
                    key.keyCollide(victime, victime.GetComponent <AudioSource>());
                }
                if (item.itemType == ItemType.Door && !pasUneVictime)
                {
                    Door door = (Door)item;

                    door.doorCollide(victime, victime.GetComponent <AudioSource>());
                }
                if (item.itemType == ItemType.Obstacle)
                {
                    colliding = true;
                }
            }
        }

        if (hitTop.collider != null)
        {
            Item item = hitTop.collider.GetComponent <Item>();
            if (item)
            {
                if (item.itemType == ItemType.Trap && !pasUneVictime)
                {
                    Trap trap = (Trap)item;
                    trap.Activate(victime, victime.GetComponent <AudioSource>());
                }
                if (item.itemType == ItemType.Bonus && !pasUneVictime)
                {
                    Bonus bonus = (Bonus)item;
                    bonus.PickUpBonus(victime, victime.GetComponent <AudioSource>());
                }


                if (item.itemType == ItemType.Key && !pasUneVictime)
                {
                    Key key = (Key)item;
                    key.keyCollide(victime, victime.GetComponent <AudioSource>());
                }
                if (item.itemType == ItemType.Door && !pasUneVictime)
                {
                    Door door = (Door)item;

                    door.doorCollide(victime, victime.GetComponent <AudioSource>());
                }
                if (item.itemType == ItemType.Obstacle)
                {
                    colliding = true;
                }
            }
        }

        if (hitLeft.collider != null)
        {
            Item item = hitLeft.collider.GetComponent <Item>();
            if (item)
            {
                if (item.itemType == ItemType.Trap && !pasUneVictime)
                {
                    Trap trap = (Trap)item;
                    trap.Activate(victime, victime.GetComponent <AudioSource>());
                }
                if (item.itemType == ItemType.Bonus && !pasUneVictime)
                {
                    Bonus bonus = (Bonus)item;
                    bonus.PickUpBonus(victime, victime.GetComponent <AudioSource>());
                }


                if (item.itemType == ItemType.Key && !pasUneVictime)
                {
                    Key key = (Key)item;
                    key.keyCollide(victime, victime.GetComponent <AudioSource>());
                }
                if (item.itemType == ItemType.Door && !pasUneVictime)
                {
                    Door door = (Door)item;

                    if (!door.isOpen)
                    {
                        colliding = true;
                    }
                    door.doorCollide(victime, victime.GetComponent <AudioSource>());
                }
                if (item.itemType == ItemType.Obstacle)
                {
                    colliding = true;
                }
            }
        }

        if (hitRight.collider != null)
        {
            Item item = hitRight.collider.GetComponent <Item>();
            if (item)
            {
                if (item.itemType == ItemType.Trap && !pasUneVictime)
                {
                    Trap trap = (Trap)item;
                    trap.Activate(victime, victime.GetComponent <AudioSource>());
                }
                if (item.itemType == ItemType.Bonus && !pasUneVictime)
                {
                    Bonus bonus = (Bonus)item;
                    bonus.PickUpBonus(victime, victime.GetComponent <AudioSource>());
                }


                if (item.itemType == ItemType.Key && !pasUneVictime)
                {
                    Key key = (Key)item;
                    key.keyCollide(victime, victime.GetComponent <AudioSource>());
                }
                if (item.itemType == ItemType.Door && !pasUneVictime)
                {
                    Door door = (Door)item;

                    door.doorCollide(victime, victime.GetComponent <AudioSource>());
                }
                if (item.itemType == ItemType.Obstacle)
                {
                    colliding = true;
                }
            }
        }



        if (colliding)
        {
            distanceToTop = hitTop.distance;

            distanceToRight = hitRight.distance;

            distanceToLeft = hitLeft.distance;

            distanceToBottom = hitBottom.distance;

            float x = centerCheck.transform.position.x - leftCheck.transform.position.x;
            float y = centerCheck.transform.position.y - bottomCheck.transform.position.y;


            if (hasObstacleBottom)
            {
                float offset = Mathf.Abs(y - distanceToBottom);
                transform.position += (new Vector3(0.0f, offset, 0));
            }

            if (hasObstacleRight)
            {
                float offset = Mathf.Abs(x - distanceToRight);
                this.transform.Translate(new Vector2(-offset, 0.0f));
            }

            if (hasObstacleLeft)
            {
                float offset = Mathf.Abs(x - distanceToLeft);
                this.transform.Translate(new Vector2(offset, 0.0f));
            }

            if (hasObstacleTop)
            {
                float offset = Mathf.Abs(y - distanceToTop);
                this.transform.Translate(new Vector2(0.0f, -offset));
            }
        }
    }