상속: MonoBehaviour, IDamageable
예제 #1
0
    public void Execute(string pObjectName, string pActionName, ActionParameter pActionParameter)
    {
        MoveableObject lObject = ObjectsItems.Items[pObjectName];
        ActionDelegate lAction = ActionItems[pActionName];

        lAction(lObject, pActionParameter);
    }
        /// <summary>
        /// Constructor for the <c>EventData_PickedObject</c> class.
        /// </summary>
        /// <param name="player">Reference to the player.</param>
        /// <param name="pObject">Reference to the picked object.</param>
        public EventData_PickedObject(Character player, MoveableObject pObject)
        {
            _eventType = EventManager.EventType_PickedObject;

            _player = player;
            _object = pObject;
        }
예제 #3
0
 public override void Execute(MoveableObject pObject, ActionParameter pActionPara)
 {
     // TODO: add the run action implementation
     // 1. get object's rigid body
     // 2. get object's animation (from file)
     // 3. run the animation with the action parameter
 }
예제 #4
0
    void Update()
    {
        float x = Input.GetAxis("Horizontal");

        if (Input.GetKeyDown(KeyCode.Space) && isGrounded)
        {
            isGrounded = false;
            rb.AddForce(jump * jumpForce, ForceMode.Impulse);
        }



        rb.velocity = new Vector3(x * speed, rb.velocity.y, 0);

        if (Input.GetKeyDown(KeyCode.E))
        {
            Flip();
        }

        if (Input.GetKeyDown(KeyCode.Q))
        {
            if (currentMoveable != null)
            {
                Rigidbody moveRb = currentMoveable.GetComponent <Rigidbody>();

                MoveableObject move = currentMoveable.GetComponent <MoveableObject>();
                moveRb.constraints  = move.rbCs;
                move.player         = gameObject;
                move.linkedToPlayer = true;
            }
        }
    }
예제 #5
0
    public override void Interact(MoveableObject controller)
    {
        if (!canInteract)
        {
            return;
        }

        // Instead of doing it the proper way, just use GetComponent to save time
        PlayerController playerController = controller.GetComponent <PlayerController>();

        Debug.Log("Deal damage interactable");
        if (playerController != null)
        {
            float knockback = 0;
            if (pushBack)
            {
                knockback = playerController.swordSwing.knockback;
            }

            Debug.Log("Deal damage interactable 2");
            double enemyToPlayerDamage = this.enemyController.playerStats.GetScaledStat(Stat.ATTACK, this.enemyController.reference);
            playerController.DealDamageToMe(enemyToPlayerDamage, knockback);


            double playerToEnemyDamage = playerController.swordSwing.GetSwordDamage() / 5.0;
            this.enemyController.hittableObject.ManualGetHit(playerToEnemyDamage, knockback);
        }
    }
예제 #6
0
파일: Program.cs 프로젝트: xyl1t/XylitAlpha
        static bool player_CollisionAction(MoveableObject sender, CollisionEventArgs e)
        {
            bool allow = true;

            if (e.CollidingObject.ObjectType == "Barrel")
            {
                (e.CollidingObject as MoveableObject).Direction = e.Direction;
                if (!(e.CollidingObject as MoveableObject).CheckCollision())
                {
                    allow = false;
                }
                (e.CollidingObject as MoveableObject).MoveDraw(e.Direction);
            }
            else if (e.CollidingObject.ObjectType == "Enemy")
            {
                if (health > 1)
                {
                    health--;
                    UpdateHealth();
                }
                else
                {
                    health--;
                    Alive = false;
                    UpdateHealth();
                    int width = 13, height = 5;
                    int x = region.Width / 2 - width / 2, y = (region.Height / 2 - height / 2) - 5;

                    Window gameOver = new Window(screen, x, y, width, height, "Game", "YOU LOOSE", ConsoleColor.White, ConsoleColor.Black, ConsoleColor.DarkRed, ConsoleColor.Red);
                    gameOver.Show();
                    Console.ReadKey(true);
                }
            }
            return(allow);
        }
예제 #7
0
        public GameMap(vec3 MapPosition, MoveableObject Camera)
        {
            this.Camera   = Camera;
            assestsCount  = 9;
            MapComponents = new Model3D[assestsCount];

            /*
             * 1: road
             * 2: road tiles
             * 3: small islands
             * 4: high rocks
             * 5: low rocks
             * 6: mountain fall
             * 7: water fall
             * 8: palms
             * 9: GroundSides
             */
            Position        = MapPosition * Constants.AspectRatio;
            translateMatrix = glm.translate(new mat4(1), Position);
            rotationMatrix  = glm.rotate((-90f / 180f) * (float)Math.PI, new vec3(0, 1, 0));
            scaleMatrix     = glm.scale(new mat4(1), new vec3(200, 200, 200) * Constants.AspectRatio);

            for (int i = 0; i < assestsCount; ++i)
            {
                MapComponents[i] = new Model3D();
            }

            currPath = Directory.GetParent(Environment.CurrentDirectory).Parent.FullName + "\\ModelFiles\\Models\\";

            Intialize();
            ApplyTransformation();
            StartZ = Position.z;
        }
    void OnTriggerEnter2D(Collider2D other)
    {
        if (Time.timeScale != 0)
        {
            _moveableObjectScript = other.GetComponent <MoveableObject> ();
            if (_moveableObjectScript != null)
            {
                if (_moveableObjectScript.isTractored)
                {
                    _blockSuccessful = true;
                    theTextBox.startCommentaryDialogue();
                    theTextBox.setVoiceOverSourceClip(audioClip2);
                    theTextBox.ReloadScript(textFileBlockSuccessful);
                    theTextBox.currentLine = startLine;
                    theTextBox.endAtLine   = endLine;
                    //theTextBox.EnableTextBox();
                    theTextBox.setSpeakerNameText(speakerName);

                    if (timedDialogue)
                    {
                        theTextBox.activateTimedCommentary(timeUntilFinished);
                    }
                    if (destroyWhenActivated)
                    {
                        Destroy(gameObject);
                    }
                }
            }
        }
    }
예제 #9
0
 public override void SetItem(MoveableObject item, string direction)
 {
     if (containsItem == null)
     {
         containsItem = item;
         containsItem.MoveableSpot = this;
         return;
     }
     else if (containsItem.IsCrate == true && item.IsCrate == true)
     {
         throw new Exception_TwoCratesInARow();
     }
     else if (containsItem.IsColleague == true && item.IsTruck)
     {
         containsItem.WakeUpColleague();
         throw new Exception_HitColleague();
     }
     else if (containsItem.IsColleague == true)
     {
         throw new Exception_HitColleague();
     }
     else
     {
         getSpotInDirection(direction).SetItem(ContainsItem, direction);
         containsItem = item;
         containsItem.MoveableSpot = this;
     }
 }
예제 #10
0
 /// <summary>
 /// Remove an object from the <c>ThrownObjectManager</c>.
 /// </summary>
 /// <param name="thrownObject">Reference to the object.</param>
 public void RemoveObject(MoveableObject thrownObject)
 {
     if (_thrownObjects.Contains(thrownObject))
     {
         _thrownObjects.Remove(thrownObject);
     }
 }
예제 #11
0
 public override void Execute(MoveableObject pObject, ActionParameter pActionPara)
 {
     // TODO: add the run action implementation
     // 1. get object's rigid body
     // 2. get object's animation (from file)
     // 3. run the animation with the action parameter
 }
예제 #12
0
 public override void OnCollide(MoveableObject Other)
 {
     if (Other.GetType() == typeof (Player))
     {
         Game.Endlevel();
     }
 }
예제 #13
0
    private void grabObject()
    {
        RaycastHit hit;

        if (Physics.Raycast(raySettings.raycastTransform.position, raySettings.raycastTransform.TransformDirection(Vector3.forward), out hit, raySettings.raycastDistance, raySettings.objectLayer))
        {
            if ((hit.collider.GetComponent("MoveableObject") as MoveableObject) != null)
            {
                crossHair.color = Color.red;
                if (m_obj != null)
                {
                    m_obj.attractState = MoveableObject.CurrentAttractState.NoneSeleceted;
                    m_obj = hit.collider.GetComponent("MoveableObject") as MoveableObject;
                    m_obj.attractState  = MoveableObject.CurrentAttractState.PlayerSelected;
                    m_obj.grabTransform = holdPos;
                }
                else
                {
                    m_obj = hit.collider.GetComponent("MoveableObject") as MoveableObject;
                    m_obj.attractState  = MoveableObject.CurrentAttractState.PlayerSelected;
                    m_obj.grabTransform = holdPos;
                }
            }
        }
        else
        {
            crossHair.color = Color.black;
        }
    }
예제 #14
0
 // Start is called before the first frame update
 void Start()
 {
     gameMaster = GameObject.FindGameObjectWithTag("GM").GetComponent <GameMaster>();
     move       = GetComponent <MoveableObject>();
     live       = GetComponent <LiveThing>();
     anim       = GetComponent <Animator>();
     player     = gameMaster.GetPlayer();
 }
예제 #15
0
 public Maze(Tile firstTile, MoveableObject player, List <FireFly> fireFlies, int originalAmountOfDiamonds, Exit exit)
 {
     _originalAmountOfDiamonds = originalAmountOfDiamonds;
     FirstTile = firstTile;
     Player    = player;
     Exit      = exit;
     FireFlies = fireFlies;
 }
예제 #16
0
파일: Magnet.cs 프로젝트: d4got10/Magnito
 public void OnObjectEnter(MoveableObject enteredObject)
 {
     if (!_moveableObjects.Contains(enteredObject))
     {
         _moveableObjects.Add(enteredObject);
         enteredObject.AddForce += AddForce;
     }
 }
예제 #17
0
파일: Magnet.cs 프로젝트: d4got10/Magnito
 public void OnObjectExit(MoveableObject enteredObject)
 {
     if (_moveableObjects.Contains(enteredObject))
     {
         _moveableObjects.Remove(enteredObject);
         enteredObject.AddForce -= AddForce;
     }
 }
예제 #18
0
        /// <summary>
        /// Constructor of the <c>EventData_PlaneCollision</c> class.
        /// </summary>
        /// <param name="mObject"><c>MoveableObject</c> that collide.</param>
        /// <param name="plane">Plane that represents the surface of the collision.</param>
        /// <param name="addValue">Value to be added to the new position.</param>
        public EventData_PlaneCollision(MoveableObject mObject, Plane plane,
                                        float addValue)
        {
            _eventType = EventManager.EventType_UnitCollision;

            _plane    = plane;
            _mObject  = mObject;
            _addValue = addValue;
        }
예제 #19
0
 private void OnTriggerEnter(Collider col)
 {
     if (col.GetComponent <MoveableObject>() != null)
     {
         MoveableObject hitObject = col.GetComponent <MoveableObject>();
         hitObject.ResetState();
         hitObject.GetComponent <Rigidbody>().velocity = Vector3.zero;
     }
 }
예제 #20
0
 public override void Interact(MoveableObject controller)
 {
     GameManager.Instance.gameController.StartCoroutine(GameManager.Instance.gameController.InstantiateRewardCor(reward, controller.transform.position + Vector3.up, controller.transform));
     if (soundEffect != null)
     {
         GameManager.Instance.audio.PlayOneShot(soundEffect, soundVolume);
     }
     Destroy(this.gameObject);
 }
예제 #21
0
        public override bool MoveTo(MoveableObject requestObject)
        {
            if (this.MoveableObject != null)
            {
                // When their is an object on current tile
                bool result;
                Tile tempTile;

                if (requestObject.Tile == LowerTile)
                {
                    tempTile = UpperTile;
                }
                else if (requestObject.Tile == LeftTile)
                {
                    tempTile = RightTile;
                }
                else if (requestObject.Tile == UpperTile)
                {
                    tempTile = LowerTile;
                }
                else if (requestObject.Tile == RightTile)
                {
                    tempTile = LeftTile;
                }
                else
                {
                    return(false);
                }

                if (!MoveableObject.CanMoveOtherObject && tempTile.MoveableObject != null && !tempTile.MoveableObject.CanMoveOtherObject)
                {
                    return(false);
                }
                else
                {
                    result = tempTile.MoveTo(this.MoveableObject);
                }

                if (!result)
                {
                    return(false);
                }
            }

            // When requestObject should be placed on current tile

            // Remove moveableobject on old tile
            requestObject.Tile.MoveableObject = null;

            // Set requestObject on current tile
            this.MoveableObject = requestObject;

            // Set requestObject tile on current tile
            requestObject.Tile = this;

            return(true);
        }
예제 #22
0
        public override void OnCollide(MoveableObject Other)
        {
            if (Other.GetType()==typeof(Player))
            {
                ((Player)Other).Weaponlist.Add(Item);
                Destroy();

            }
        }
예제 #23
0
 private void AllowFlight(MoveableObject pFlyingObject)
 {
     DistanceJoint2D existingDistanceJoint = mBalloon.Physics.DistanceJoint2D;
     existingDistanceJoint.enabled = false;
     DistanceJoint2D objectDistanceJoint = pFlyingObject.GetDistanceJoint ();
     objectDistanceJoint.connectedBody = mBalloon.Physics.GetRigidBody();
     objectDistanceJoint.enabled = true;
     pFlyingObject.SetIsFlying (true);
 }
    void Update()
    {
        if (playerEntered)
        {
            //center point of viewport in World space.
            Vector3    rayOrigin = fpsCam.ViewportToWorldPoint(new Vector3(0.5f, 0.5f, 0f));
            RaycastHit hit;

            //if raycast hits a collider on the rayLayerMask
            if (Physics.Raycast(rayOrigin, fpsCam.transform.forward, out hit, reachRange, rayLayerMask))
            {
                MoveableObject moveableObject = null;
                //is the object of the collider player is looking at the same as me?
                if (!isEqualToParent(hit.collider, out moveableObject))
                {                       //it's not so return;
                    return;
                }

                if (moveableObject != null)                             //hit object must have MoveableDraw script attached
                {
                    string animBoolNameNum = animBoolName + moveableObject.objectNumber.ToString();

                    bool isOpen = anim.GetBool(animBoolNameNum);                        //need current state for message.

                    //if (Input.GetKeyUp(KeyCode.E) || Input.GetButtonDown("Fire1"))
                    //{
                    anim.enabled = true;
                    anim.SetBool(animBoolNameNum, !isOpen);
                    //}
                }
            }
        }

        if (player2Entered)
        {
            string animBoolNameNum = animBoolName + "1";
            bool   isOpen          = anim.GetBool(animBoolNameNum);
            if (isOpen)
            {
                anim.enabled = true;
                anim.SetBool(animBoolNameNum, !isOpen);
            }
        }

        if (player2Left)
        {
            string animBoolNameNum = animBoolName + "1";
            bool   isOpen          = anim.GetBool(animBoolNameNum);
            if (!isOpen)
            {
                anim.enabled = true;
                anim.SetBool(animBoolNameNum, isOpen);
            }
            player2Left = false;
        }
    }
예제 #25
0
 private void OnTriggerExit(Collider other)
 {
     if (other.gameObject.tag == "Moveable")
     {
         MoveableObject move = currentMoveable.GetComponent <MoveableObject>();
         move.player         = null;
         move.linkedToPlayer = false;
         currentMoveable     = null;
     }
 }
예제 #26
0
        /// <summary>
        /// The ability has stopped running.
        /// </summary>
        protected override void AbilityStopped()
        {
            base.AbilityStopped();

            m_MoveableObject.StopMove();
            m_MoveableTransform          = null;
            m_MoveableObject             = null;
            m_Controller.ForceRootMotion = false;
            m_InPosition = false;
        }
예제 #27
0
 private void Awake()
 {
     m_MovableObject = GetComponent <MoveableObject>();
     m_Rigidbody     = GetComponent <Rigidbody>();
     m_ObjectManager = FindObjectOfType <ObjectsManager>();
     if (m_ObjectManager)
     {
         m_ObjectManager.m_ChairList.Add(this);
     }
 }
예제 #28
0
    // Start is called before the first frame update
    void Start()
    {
        mObject = gameObject.GetComponent<MoveableObject>();
        GM = GameObject.Find("GameManager").GetComponent<GameManager>();
        audioManager = GameObject.Find("PlayerCanvas").GetComponent<AudioManager>();
        playerSpriteHeight = gameObject.GetComponent<SpriteRenderer>().bounds.extents.y;
        playerCollider = gameObject.GetComponent<BoxCollider2D>();

        contactFilter = new ContactFilter2D();
        contactFilter.useTriggers = true;
    }
예제 #29
0
 public void Add(MoveableObject mo)
 {
     if (isRunning)
     {
         addStack.Add(mo);
     }
     else
     {
         objects.Add(mo);
     }
 }
예제 #30
0
 public void Remove(MoveableObject mo)
 {
     if (isRunning)
     {
         removeStack.Add(mo);
     }
     else
     {
         objects.Remove(mo);
     }
 }
예제 #31
0
 public void Remove(MoveableObject mo)
 {
     if (isRunning)
     {
         removeStack.Add(mo);
     }
     else
     {
         objects.Remove(mo);
     }
 }
예제 #32
0
 public void Add(MoveableObject mo)
 {
     if (isRunning)
     {
         addStack.Add(mo);
     }
     else
     {
         objects.Add(mo);
     }
 }
예제 #33
0
        /// <summary>
        /// Constructor of the <c>EventData_ObjectsCollision</c> class.
        /// </summary>
        /// <param name="mObject"><c>MoveableObject</c> that collide with a node.</param>
        /// <param name="node">Node collisioned with the <c>MoveableObject</c>.</param>
        /// <param name="direction">Direction of the collision.</param>
        /// <param name="type">Type of surface collision.</param>
        /// <param name="addValue">Value to be added to the new position.</param>
        public EventData_ObjectsCollision(MoveableObject mObject, ref OcTreeNode node,
                                          CollisionDirection direction, CollisionSurface type, float addValue)
        {
            _eventType = EventManager.EventType_UnitCollision;

            _addValue  = addValue;
            _direction = direction;
            _type      = type;
            _node      = node;
            _mObject   = mObject;
        }
예제 #34
0
    void Start()
    {
        gameMaster = GameObject.FindGameObjectWithTag("GM").GetComponent <GameMaster>();
        move       = GetComponent <MoveableObject>();
        live       = GetComponent <LiveThing>();
        anim       = GetComponent <Animator>();
        player     = gameMaster.GetPlayer();

        healthbar.SetMaxHealth(live.health.initValue);
        healthbar.SetHealth(live.health.initValue);
    }
예제 #35
0
 public override void Interact(MoveableObject controller)
 {
     if (Mathf.Sign(controller.horizontalMoveSpeed) == Mathf.Sign(bounceStrength))
     {
         controller.moveDirection.x = 1 * Mathf.Sign(controller.horizontalMoveSpeed);
     }
     else
     {
         controller.moveDirection.x = bounceStrength;
     }
 }
예제 #36
0
 public override void OnCollide(MoveableObject Other)
 {
     if (Other != null)
     {
         if (Other.GetType() == typeof(Enemy))
         {
             ((Enemy)Other).Health -= Damage;
         }
     }
     Destroy();
 }
예제 #37
0
    private void Start()
    {
        anim  = GetComponent <Animator>();
        move  = GetComponent <MoveableObject>();
        enemy = GetComponent <Enemy>();

        var position = transform.position;

        spawnPoint         = new Vector3(position.x, position.y, position.z);
        currentPatrolPoint = spawnPoint;
    }
예제 #38
0
 /// <summary>
 /// Adds Object to DestroyCandidates, which are removed every frame
 /// </summary>
 /// <param name="obj">Object to Remove</param>
 public static void Remove(MoveableObject obj)
 {
     EntitiesToDestroy.Add(obj);
 }
예제 #39
0
 /// <summary>
 /// Adds Object to Manager
 /// </summary>
 /// <param name="obj">Object to add</param>
 public static void Add(MoveableObject obj)
 {
     EntitiesToAdd.Add(obj);
 }
예제 #40
0
 public abstract void Execute(MoveableObject pObjectName, ActionParameter pActionPara);
예제 #41
0
 public override void OnCollide(MoveableObject Other)
 {
     if (Other == Player)
         Attack(Player);
 }
예제 #42
0
 public void Add( string pName, MoveableObject pObject )
 {
     Items.Add(pName, pObject);
 }