예제 #1
0
 // Start is called before the first frame update
 void Start()
 {
     this.anim  = GetComponent <Animator>();
     arm        = FindObjectOfType <arm>();
     active     = true;
     this.tform = GetComponent <Transform>();
 }
예제 #2
0
        /// <summary>
        /// Allows the game component to perform any initialization it needs to before starting
        /// to run.  This is where it can query for any required services and load content.
        /// </summary>
        public override void Initialize()
        {
            this.frame = 0;
            _Xvelocity = 0;
            _Yvelocity = 0;
            jumping    = true;
            kicking    = false;

            playerArm = new arm(_game, _playgame, "armsheet", vector.X, vector.Y);

            base.Initialize();
        }
예제 #3
0
    //remember for cylinder, width (y - scale) is half of real

    public void Init(Vector3 position, float angle)
    {
        //следующее звено
        FixedJoint fixedjoint   = GetComponent <FixedJoint>();
        GameObject next         = fixedjoint.connectedBody.gameObject;
        arm        nextbehavior = fixedjoint.connectedBody.GetComponent <arm>();

        //размещаем следующее звено
        next.transform.localScale = new Vector3(nextbehavior.width, nextbehavior.length, nextbehavior.width);
        next.transform.position   = new Vector3(transform.position.x, transform.position.y + (diameter + nextbehavior.length) / 2, transform.position.z);

        //якорь шарнира
        fixedjoint.anchor = new Vector3(0.0f, 0.5f, 0.0f);

        //инициализируем следующие звенья
        nextbehavior.Init(position, angle);

        //поворачиваем вокруг вертикальной оси
        transform.RotateAround(position, Vector3.down, angle);
    }
예제 #4
0
    public bool CheckStaticFrames (ref arm theArm)
    {
        int frames_cap1 = 15;
        int frames_cap2 = 30;
        int frames_cap3 = 45;
        //Depending on the number of frames
        //A 0-15 change color to white 


        if(theArm.handOnCooldown){

            theArm.rayColor = Color.yellow;
            theArm.frameCount = 0;
        }
        else if (theArm.deactivated){
            theArm.rayColor = Color.yellow;
            theArm.frameCount = 0;

        }


        else
        {

            if (theArm.frameCount < frames_cap1)
            {
                theArm.rayColor = Color.white;
                return false;
            }

            //B 15-30 change color to blue
            else if (theArm.frameCount > frames_cap1 && theArm.frameCount < frames_cap2)
            {
                theArm.rayColor = Color.blue;

            }


            //C +30 change color to red and ready to deploy
            else if (theArm.frameCount > frames_cap2)
            {
                theArm.rayColor = Color.green;
                return true;      // IF we reach this point there is no need to keep checking this
            }

        }

        

        return false;
    }
예제 #5
0
    /*
        ExpandObject

        */


    void ExpandObject(arm theArm, Vector3 direction)
    {
        float scalingDuration = 0.3f;
        Vector3 newScale = new Vector3(rightArm.Prefab.transform.localScale.x + direction.x * 5, rightArm.Prefab.transform.localScale.y, rightArm.Prefab.transform.localScale.z);
        float scaleStep = Time.deltaTime / scalingDuration;
        rightArm.Prefab.transform.localScale = Vector3.Lerp(transform.localScale, newScale, scaleStep);

    }
예제 #6
0
 /*
     checkIfActive: the input arm is occupied        
     */
 void checkIfActive(ref arm theArm)
 {
     if (!theArm.runningPositionLocation)
     {
         print(theArm.runningPositionLocation);
         print("Starting Courutine with: "+ theArm.ObjHand.name+ "\n");
         StartCoroutine( FixedPointer(theArm));
     }
     else
     {
         print("A courutine was running already for: " + theArm.ObjHand.name + "So ignore\n");
     }
 }
예제 #7
0
    /*
        DismissAction
        */

    void DismissAction (arm theArm)
    {

    }
예제 #8
0
    /*
        UpdateRayPointer. Find if we should cast a ray
    */

    Vector3 UpdateRayPointer(ref arm theArm)
    {

        Vector3 RayColission = new Vector3(0,0,0);
        
        RaycastHit hit;
        theArm.pointer = RayColission;
        //Color rayColor = RayColor;


        Vector3 Ref1 = theArm.ObjHand.transform.position;
        Vector3 Ref2 = theArm.ObjElvow.transform.position;
        Vector3 Ref3 = theArm.ObjShoulder.transform.position;

        Vector3 Direction = JointRelativePosition(Ref2, Ref1, false);

        Ray theRay = new Ray(Ref1, Direction);
        Physics.Raycast(theRay, out hit, 100);
        theArm.ObjectHit = hit.transform.gameObject;
        theArm.pointer = hit.point;
        Debug.DrawLine(Ref1, hit.point, theArm.rayColor);

        return hit.point;
    }
예제 #9
0
    /*
        This will run in the background


        If succedded it will start a cooldown
        */
    public IEnumerator FixedPointer(arm TheArm)
    {
        TheArm.runningPositionLocation = true;
        float smallDistance = 2f;
        float LargeDistance = 4f;
        Vector3 OPoint = TheArm.pointer;
        Vector3 thePoint;
        bool isDone = false;
        bool check = false;

        print("First Position of " + TheArm.ObjHand.name + " is" + OPoint);


        //StartCoroutine(Wait(3f, TheArm));
        print("Waiting for" + 3f + "seconds....... TIME ="+ Time.time);
        yield return new WaitForSeconds(3f);
        print("End Waiting for" + 3f + "seconds....... TIME =" + Time.time);

        // get the point
        
        thePoint = TheArm.pointer;
        print("Second Position of " + TheArm.ObjHand.name + " is" + thePoint);
        check = checkRayOnPoint(smallDistance, thePoint, OPoint);
        if (check)
        {
            print(smallDistance + "distance is "+ check);
            TheArm.rayColor = Color.blue;
            float distance = Vector3.Distance(thePoint, OPoint);
            /*
            StartCoroutine(Wait(0.3f));
            // get the point
            print("runing second part of the courutine");
            thePoint = TheArm.pointer;

            if (checkRayOnPoint(smallDistance, thePoint, OPoint))
            {
                print(smallDistance + "distance");
                RayColor = Color.blue;
                distance = Vector3.Distance(thePoint, OPoint);
            }

            */

        }
        else
        {
            
            print("Aborting wait, at time = " + Time.time);
            TheArm.rayColor = Color.white;
            TheArm.runningPositionLocation = false;

        }


        
        


        /*
        UpdateRayPointer(TheArm);
        thePoint = TheArm.pointer;
        check = checkRayOnPoint(smallDistance, OPoint, thePoint);
        if (check)
        {

        }
        else
            isDone = true;

        */
        TheArm.runningPositionLocation = true;
        // Get where the raycast hits thePoint = 

        

        //This is a coroutine
        //isStopped = false;
        //Vector3 velocityBall = gameController.StartKick(gameController.BallSpeed, direction);
        //GetComponent<Rigidbody>().velocity = velocityBall;
    }
예제 #10
0
    public IEnumerator WaitNDestroy(float waitTime, arm TheArm)
    {

        TheArm.handOnCooldown = true;
        print("Start Waiting for" + waitTime + "seconds");
        yield return new WaitForSeconds(waitTime);
        print("End Waiting for" + waitTime + "seconds");
        Destroy(TheArm.Prefab);
        TheArm.handOnCooldown = false;


    }
예제 #11
0
        /// <summary>
        /// Allows the game component to update itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            //First, it runs the draw logic and the timer logic of the AnimatedGameObject class (see AnimatedGameObject.cs)
            base.Update(gameTime);

            //on every update, it draws a new hitbox, as it extends a bit in front of the character to determine future collision.
            hitbox = new Rectangle(((int)(this.vector.X + ((this.spriteWidth / 2) - 15)) + _Xvelocity), ((int)this.vector.Y + _Yvelocity), 30, this.spriteHeight);

            //it also gets a list of all the ground objects Rimbo can land on. This includes destructible objects he can land on.
            //This needs to happen every update, as the state of these destructible objects can change.
            map = new List <ground>(_game.Components.OfType <ground>());

            //Adjusting the basic movement based on the character's velocity, as well as locking him to the screen.
            this.vector.X += _Xvelocity;
            this.vector.Y += _Yvelocity;
            this.vector.X  = MathHelper.Clamp(this.vector.X, 0, (_game.GraphicsDevice.Viewport.Width - 72));
            this.vector.Y  = MathHelper.Clamp(this.vector.Y, 0, (_game.GraphicsDevice.Viewport.Height));

            //Gravity. Rimbo can fall no faster than 15 pixels per frame, but speeds up until he does.
            if (_Yvelocity < 15)
            {
                _Yvelocity++;
            }
            else
            {
                _Yvelocity = 15;
            }

            //All ground or obstacle objects are checked, to adjust Rimbo's velocity as required; he hits something, he stops.
            foreach (ground Q in map)
            {
                if (this.hitbox.Intersects(Q.wallboxleft))
                {
                    _Xvelocity    = 0;
                    this.vector.X = (Q.vector.X - 50);
                }

                if (this.hitbox.Intersects(Q.wallboxright))
                {
                    _Xvelocity    = 0;
                    this.vector.X = (Q.vector.X + Q.spriteWidth) - 22;
                }

                if (this.hitbox.Intersects(Q.groundbox))
                {
                    jumping       = false;
                    _Yvelocity    = 0;
                    this.vector.Y = (Q.vector.Y - 72);
                }
            }

            //Determines how to draw the Sprite based on which way Rimbo is facing.
            if (right)
            {
                this.spriteMirror      = SpriteEffects.None;
                playerArm.spriteMirror = SpriteEffects.None;

                playerArm.vector.Y = this.vector.Y + 25;
                playerArm.vector.X = this.vector.X + 27;
                playerArm.origin   = new Vector2(5, 9);

                playerArm.spriteRotation = 0 + mousePosition();
            }
            else if (!right)
            {
                this.spriteMirror      = SpriteEffects.FlipHorizontally;
                playerArm.spriteMirror = SpriteEffects.FlipHorizontally;

                playerArm.vector.Y = this.vector.Y + 25;
                playerArm.vector.X = this.vector.X + 42;
                playerArm.origin   = new Vector2(57, 9);

                playerArm.spriteRotation = 0 - mousePosition();
            }

            //Input handling.
            KeyboardState keystate = Keyboard.GetState();

            if (keystate.IsKeyDown(Keys.Space) && !jumping || keystate.IsKeyDown(Keys.RightShift) && !jumping)
            {
                //Set Rimbo to his jumping animation, give him an upward velocity and lock controls by setting jumping to true.
                this.frame = 5;
                _Yvelocity = -15;
                jumping    = true;
            }

            if (keystate.IsKeyDown(Keys.Right) || keystate.IsKeyDown(Keys.D))
            {
                //make Rimbo face right.
                right = true;

                //Speed Rimbo up until he hits a certain speed.
                if (_Xvelocity <= 3)
                {
                    _Xvelocity += 1;
                }
                else
                {
                    _Xvelocity = 3;
                }

                //move Rimbo's frame up every time the animation timer depletes.
                if (this.animationTimer == 0 && !jumping)
                {
                    this.frame++;
                    //unless he hit the ending of this animation, then return to the first frame.
                    if (this.frame > 4)
                    {
                        frame = 1;
                    }
                }
            }
            else if (keystate.IsKeyDown(Keys.Left) || keystate.IsKeyDown(Keys.A))
            {
                //make rimbo face left, same as above.
                right = false;

                if (_Xvelocity >= -3)
                {
                    _Xvelocity -= 1;
                }
                else
                {
                    _Xvelocity = -3;
                }

                if (this.animationTimer == 0 && !jumping)
                {
                    this.frame++;
                    if (this.frame > 4)
                    {
                        frame = 1;
                    }
                }
            }

            if (keystate.IsKeyDown(Keys.Down) || keystate.IsKeyDown(Keys.S))
            {
                //Display Rimbo's ducking animation.
                _Xvelocity = 0;
                this.frame = 6;

                //Adjust the arm object accoardingly.
                playerArm.vector.Y += 10;
                if (right)
                {
                    playerArm.vector.X += 5;
                }
                else if (!right)
                {
                    playerArm.vector.X -= 5;
                }
            }

            if (keystate.IsKeyDown(Keys.LeftControl) && !kicking || keystate.IsKeyDown(Keys.RightControl) && !kicking)
            {
                //make Rimbo kick
                kicking = true;
            }

            if (kicking)
            {
                //When kicking, Rimbo comes to a halt,
                _Xvelocity = 0;

                if (this.animationTimer == 0)
                {
                    //Adjust his animation.
                    this.frame++;
                    if (this.frame < 7)
                    {
                        this.frame = 7;
                    }
                    if (this.frame > 9)
                    {
                        //disable the kicking animation and go back to idle after the animation is finished.
                        kicking    = false;
                        this.frame = 0;
                    }
                }
            }

            //The idle state.
            if (keystate.IsKeyUp(Keys.Space) && keystate.IsKeyUp(Keys.RightShift) && keystate.IsKeyUp(Keys.Right) && keystate.IsKeyUp(Keys.D) && keystate.IsKeyUp(Keys.Left) && keystate.IsKeyUp(Keys.A) && keystate.IsKeyUp(Keys.S) && keystate.IsKeyUp(Keys.Down) && keystate.IsKeyUp(Keys.RightControl) && keystate.IsKeyUp(Keys.LeftControl) && !kicking)
            {
                _Xvelocity = 0;
                this.frame = 0;
            }

            //This logic checks which item the player is currently holding.
            switch (_playgame.inventory.current)
            {
            case "none":
            {
                if (playerArm is Pistol || playerArm is P90 || playerArm is G36C || playerArm is MINIMI || playerArm is L96)
                {
                    if (_game.Components.Contains(playerArm))
                    {
                        _game.Components.Remove(playerArm);
                    }
                    //It then replaces the Arm with the arm of that type.
                    playerArm = new arm(_game, _playgame, "armsheet", vector.X, vector.Y);
                    _game.Components.Add(playerArm);
                }
                break;
            }

            case "pistol":
            {
                if (!(playerArm is Pistol))
                {
                    if (_game.Components.Contains(playerArm))
                    {
                        _game.Components.Remove(playerArm);
                    }
                    playerArm = new Pistol(_game, _playgame, vector.X, vector.Y);
                    _game.Components.Add(playerArm);
                }
                break;
            }

            case "SMG":
            {
                if (!(playerArm is P90))
                {
                    if (_game.Components.Contains(playerArm))
                    {
                        _game.Components.Remove(playerArm);
                    }
                    playerArm = new P90(_game, _playgame, vector.X, vector.Y);
                    _game.Components.Add(playerArm);
                }
                break;
            }

            case "Rifle":
            {
                if (!(playerArm is G36C))
                {
                    if (_game.Components.Contains(playerArm))
                    {
                        _game.Components.Remove(playerArm);
                    }
                    playerArm = new G36C(_game, _playgame, vector.X, vector.Y);
                    _game.Components.Add(playerArm);
                }
                break;
            }

            case "Machine":
            {
                if (!(playerArm is MINIMI))
                {
                    if (_game.Components.Contains(playerArm))
                    {
                        _game.Components.Remove(playerArm);
                    }
                    playerArm = new MINIMI(_game, _playgame, vector.X, vector.Y);
                    _game.Components.Add(playerArm);
                }
                break;
            }

            case "Sniper":
            {
                if (!(playerArm is L96))
                {
                    if (_game.Components.Contains(playerArm))
                    {
                        _game.Components.Remove(playerArm);
                    }
                    playerArm = new L96(_game, _playgame, vector.X, vector.Y);
                    _game.Components.Add(playerArm);
                }
                break;
            }
            }
        }
예제 #12
0
 public SimpleItemObject(arm instance)
 {
     _internal = instance;
 }
예제 #13
0
		The execution architecture (arm, amd64, etc.)