예제 #1
0
    /// <summary>
    /// 获取玩家当前是否可以移动
    /// </summary>
    /// <param name="luaState"></param>
    /// <returns></returns>
    public static int GetPlayerIsMovable(ILuaState luaState)
    {
        bool isMovable = PlayerInterface.GetInstance().GetCharacter().IsMovable;

        luaState.PushBoolean(isMovable);
        return(1);
    }
예제 #2
0
    /// <summary>
    /// 设置直线运动参数
    /// </summary>
    /// <param name="luaState"></param>
    /// <returns></returns>
    public static int STGMovableSetStraightParas(ILuaState luaState)
    {
        ISTGMovable movableObject = luaState.ToUserData(-6) as ISTGMovable;
        float       v             = (float)luaState.ToNumber(-5);
        float       angle         = (float)luaState.ToNumber(-4);
        bool        isAimToPlayer = luaState.ToBoolean(-3);
        float       acce          = (float)luaState.ToNumber(-2);
        float       accAngle;

        if (luaState.Type(-1) == LuaType.LUA_TBOOLEAN && luaState.ToBoolean(-1) == true)
        {
            accAngle = angle;
        }
        else
        {
            accAngle = (float)luaState.ToNumber(-1);
        }
        if (isAimToPlayer)
        {
            Vector2 playerPos = PlayerInterface.GetInstance().GetCharacter().GetPosition();
            float   relAngle  = MathUtil.GetAngleBetweenXAxis(playerPos - movableObject.GetPosition());
            angle    += relAngle;
            accAngle += relAngle;
        }
        movableObject.SetStraightParas(v, angle, acce, accAngle);
        return(0);
    }
예제 #3
0
 public override void Input(PlayerInterface player, Vector2 movement, bool firing)
 {
     if (movement.y > 0)
     {
         for (int i = 0; i < engines.Count; i++)
         {
             if (engines[i].HasThrust())
             {
                 rig.AddForce(handler.transform.up * engines[i].GetThrust());
                 engines[i].Fire();
             }
         }
     }
     if (movement.x != 0)
     {
         for (int i = 0; i < engines.Count; i++)
         {
             if (engines[i].HasThrust())
             {
                 rig.AddTorque(-movement.x * engines[i].torqueForce);
                 engines[i].Fire();
             }
         }
     }
 }
예제 #4
0
 protected virtual void CheckCollisionWithCharacter()
 {
     if (!_detectCollision) return;
     if (_curWidth == 0 || _curLength == 0 || _curAlpha < 1) return;
     Vector2 center = new Vector2();
     float cos = Mathf.Cos(_curRotation * Mathf.Deg2Rad);
     float sin = Mathf.Sin(_curRotation * Mathf.Deg2Rad);
     // 矩形中心坐标
     center.x = _laserHalfLength * cos + _curPos.x;
     center.y = _laserHalfLength * sin + _curPos.y;
     Vector2 vec = _player.GetPosition() - center;
     float dw = Mathf.Max(0, Mathf.Abs(cos * vec.x + sin * vec.y) - _laserHalfLength);
     float tmpY = Mathf.Abs(-sin * vec.x + cos * vec.y);
     float dh = Mathf.Max(0, tmpY - _laserHalfWidth);
     float sqrDis = dw * dw + dh * dh;
     if (sqrDis <= _player.grazeRadius * _player.grazeRadius)
     {
         if (!_isGrazed)
         {
             _isGrazed = true;
             PlayerInterface.GetInstance().AddGraze(1);
             _grazeCoolDown = GrazeCoolDown;
         }
         dh = Mathf.Max(0, tmpY - _laserHalfWidth * _collisionFactor);
         sqrDis = dw * dw + dh * dh;
         if (sqrDis <= _player.collisionRadius * _player.collisionRadius)
         {
             Eliminate(eEliminateDef.HitPlayer);
             PlayerInterface.GetInstance().GetCharacter().BeingHit();
         }
     }
 }
예제 #5
0
 private void Start()
 {
     weapon          = GameObject.Find("Player").GetComponent <PlayerController>().weapon;
     playerInterface = GameObject.Find("Player").GetComponent <PlayerInterface>();
     //debug
     weapon.weaponReady = true;
 }
예제 #6
0
 public override void Activate(PlayerInterface player)
 {
     connectedPlayer = player;
     player.SetShipInterface(this);
     busy = true;
     print("Activate");
 }
예제 #7
0
 void Start()
 {
     player   = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerController>();
     cont     = GetComponent <BallBotController> ();
     animator = GetComponent <Animator> ();
     ActionDone();
 }
 protected virtual void CheckCollisionWithCharacter()
 {
     for (int i = 0; i < _laserSegmentCount; i++)
     {
         Vector2 segmentVec = _laserSegmentList[i].GetSegmentVec();
         // 分段长度小于等于0,不进行判定
         if (segmentVec.y - segmentVec.x <= 0)
         {
             continue;
         }
         // 直线碰撞检测
         float minDis = MathUtil.GetMinDisFromPointToLineSegment(_pathList[(int)segmentVec.x], _pathList[(int)segmentVec.y], Global.PlayerPos);
         // 擦弹判断
         if (minDis <= DefaultCollisionHalfHeight + Global.PlayerGrazeRadius)
         {
             if (!_isGrazed)
             {
                 _isGrazed      = true;
                 _grazeCoolDown = GrazeCoolDown;
                 PlayerInterface.GetInstance().AddGraze(1);
             }
             if (minDis <= DefaultCollisionHalfHeight + Global.PlayerCollisionVec.z)
             {
                 PlayerInterface.GetInstance().GetCharacter().BeingHit();
                 // 直线激光击中玩家不消除
                 //Eliminate(eEliminateDef.HitPlayer);
             }
         }
     }
 }
예제 #9
0
    private void RenderPlayer()
    {
        CharacterBase player = PlayerInterface.GetInstance().GetCharacter();
        Color         col    = new Color(50f / 255, 255f / 255, 50f / 255);

        RenderCircle(player.GetPosition(), player.collisionRadius, col);
    }
예제 #10
0
 public override bool FollowCondition()
 {
     if (critter != null && critter.target != null)
     {
         PlayerInterface playerInterface = critter.target.GetComponent <PlayerInterface>();
         if (playerInterface != null)
         {
             if (playerInterface.inventory.inventory.items.Count > 0)
             {
                 int count = 0;
                 List <InventoryItem> playerItems = playerInterface.inventory.inventory.items;
                 foreach (InventoryItem item in playerItems)
                 {
                     if (item.data == targetObject.data)
                     {
                         count += item.amount;
                     }
                     if (count >= itemsNeeded)
                     {
                         return(true);
                     }
                 }
             }
         }
     }
     return(false);
 }
예제 #11
0
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
 }
예제 #12
0
    private void UpdateGrazeValue()
    {
        int graze = PlayerInterface.GetInstance().GetGraze();

        if (graze != _curGraze)
        {
            int bit = GetBit(graze);
            // 显示、隐藏多余的位数
            if (bit > _grazeBitCount)
            {
                for (int i = _grazeBitCount; i < bit; i++)
                {
                    _grazeImgList[i].gameObject.SetActive(true);
                }
            }
            else if (bit < _grazeBitCount)
            {
                for (int i = bit; i < _grazeBitCount; i++)
                {
                    _grazeImgList[i].gameObject.SetActive(false);
                }
            }
            // 从个位开始显示擦弹数目
            int num;
            for (int i = bit; i > 0; i--)
            {
                num = graze % 10;
                _grazeImgList[i - 1].sprite = ResourceManager.GetInstance().GetSprite(Consts.STGMainViewAtlasName, BigNumStr + num);
                graze /= 10;
            }
        }
    }
예제 #13
0
        public void Initialize(ContentManager Content)
        {
            BulletTexture = Content.Load <Texture2D>("Sprites/Bullet");

            CursorInfo = new CursorInfo(MouseCursor.FromTexture2D(Content.Load <Texture2D>("Sprites/CrossHair"), 0, 0), true);

            //Initialize map and camera
            mapRenderer = new TiledMapRenderer();
            camera      = new Camera(ScreenManager.GraphicsDevice);
            hubMap      = Map.LoadTiledMap(ScreenManager.GraphicsDevice, "Content/maps/hub.tmx");
            ScreenManager.Game.IsMouseVisible = false;

            //Create the player
            player = new Player(Content.Load <Texture2D>("Sprites/Player"), new Vector2(456, 456), hubMap, Content, ScreenManager);

            //Initialize some systems
            ParticleSystem.Instance.Initialize(Content);
            EntityManager.Instance.Initialize(player.playerController);
            hubMap.LoadObjects(ScreenManager);

            //Add new entities
            EntityManager.Instance.AddEntity(player);

            //Create player interface
            playerInterface = new PlayerInterface(player, Content, ScreenManager.GraphicsDevice);
            player.playerController.OnControlChanged += playerInterface.ChangeInterface;
        }
예제 #14
0
 private void Awake()
 {
     playerInterface = GetComponent <PlayerInterface>();
     photonView      = GetComponent <PhotonView>();
     gameManager     = GameObject.Find("Game Manager").GetComponent <Com.SHUPDP.JUST.GameManager>();
     torch           = GetComponentInChildren <Light>();
 }
예제 #15
0
 private void Awake()
 {
     muzzle          = transform.Find("Muzzle");
     photonView      = GetComponentInParent <PhotonView>();
     playerInterface = GetComponentInParent <PlayerInterface>();
     audioSource     = GetComponent <AudioSource>();
 }
예제 #16
0
 void Awake()
 {
     Boss.boss = this;
     player    = GameObject.FindGameObjectWithTag("Player");
     playerInt = player.GetComponent <PlayerController>();
     motor     = GetComponent <BallBotMotor> ();
 }
예제 #17
0
    /// <summary>
    /// Update whole level logic queue and force every other <c>Entity</c> to update.
    /// Used in <c>PlayerInterface</c>, when player requests an update.
    /// </summary>
    /// <param name="pi">Player interface (used to </param>
    public void requestUpdate(PlayerInterface pi)
    {
        foreach (var ent in entities)
        {
            ent.pushRequest();

            if (ent.hasRequest)
            {
                var req   = ent.request;
                var valid = req.validateRequest(this);

                if (valid)
                {
                    req.onValid(this);
                }
                else
                {
                    req.onInvalid(this);
                }

                if (req.isCallerPlayer)
                {
                    pi.requestResponse = valid ? Response.Allow : Response.Deny;
                }

                ent.clearRequest();
            }
        }
    }
예제 #18
0
    /// <summary>
    /// 做加速运动(限制最大速度)
    /// <para>bullet 敌机子弹</para>
    /// <para>float acce 加速度</para>
    /// <para>float angle 速度方向 or bool useVAngle使用速度方向</para>
    /// <para>bool isAimToPlayer 是否朝向玩家</para>
    /// <para>float maxVelocity 最大速度限制</para>
    /// </summary>
    /// <param name="luaState"></param>
    /// <returns></returns>
    public static int EnemyBulletDoAccelerationWithLimitation(ILuaState luaState)
    {
        EnemyBulletBase bullet = luaState.ToUserData(-5) as EnemyBulletBase;
        float           acce   = (float)luaState.ToNumber(-4);
        float           angle;

        if (luaState.Type(-3) == LuaType.LUA_TBOOLEAN)
        {
            bullet.GetBulletPara(BulletParaType.VAngel, out angle);
        }
        else
        {
            angle = (float)luaState.ToNumber(-3);
        }
        bool  isAimToPlayer = luaState.ToBoolean(-2);
        float maxVelocity   = (float)luaState.ToNumber(-1);

        luaState.Pop(5);
        if (isAimToPlayer)
        {
            Vector2 playerPos = PlayerInterface.GetInstance().GetCharacter().GetPosition();
            angle += MathUtil.GetAngleBetweenXAxis(playerPos - bullet.GetPosition());
        }
        bullet.DoAccelerationWithLimitation(acce, angle, maxVelocity);
        return(0);
    }
예제 #19
0
    /*
     * private float checkVertical(int col, int row)
     * {
     *  int column = col;
     *  float res = 0.0f;
     *  if (row > 0)
     *  {
     *      if (fields[column][row - 1].GetPlayer().Equals(currentPlayer))
     *      {
     *          res += 1f;
     *          return res += checkVertical(col, row - 1);
     *      }
     *  }
     *  return res;
     * }
     *
     *
     * private float checkHorizontal(int col, int row, bool increment)
     * {
     *  float res = 0.0f;
     *  if (row > VerticalSize - 1) return res;
     *
     *  string side;
     *  if (increment) side = "right";
     *  else side = "left";
     *
     *  // Debug.Log("checking horizontal " + side + " from [" + (col - 1)+ ", " + row + "]");
     *
     *  int column = col - 1;
     *  // changed below to minus two to find "off-by-1" error... ... ...
     *  if (increment && column < HorizontalSize - 1)
     *  {
     *      if (fields[column + 1][row].GetPlayer().Equals(currentPlayer))
     *      {
     *          res += 1f;
     *
     *          return res += checkHorizontal(col + 1, row, increment);
     *      }
     *  }
     *  if (!increment && column > 0)
     *  {
     *      if (fields[column - 1][row].GetPlayer().Equals(currentPlayer))
     *      {
     *          res += 1f;
     *          return res += checkHorizontal(col - 1, row, increment);
     *      }
     *  }
     *  return res;
     * }
     *
     * private float checkDiagonalUp(int col, int row, bool increment)
     * {
     *  int column = col - 1;
     *  float res = 0.0f;
     *  if (increment && column < HorizontalSize - 1 && row < VerticalSize - 1)
     *  {
     *      if (fields[column + 1][row + 1].GetPlayer().Equals(currentPlayer))
     *      {
     *          res += 1f;
     *          return res += checkDiagonalUp(col + 1, row + 1, increment);
     *      }
     *  }
     *  if (!increment && column > 0 && row > 0)
     *  {
     *      if (fields[column - 1][row - 1].GetPlayer().Equals(currentPlayer))
     *      {
     *          res += 1f;
     *          return res += checkDiagonalUp(col - 1, row - 1, increment);
     *      }
     *  }
     *  return res;
     * }
     *
     * private float checkDiagonalDown(int col, int row, bool increment)
     * {
     *  int column = col - 1;
     *  float res = 0.0f;
     *  if (increment && column > 0 && row < VerticalSize - 1)
     *  {
     *      if (fields[column - 1][row + 1].GetPlayer().Equals(currentPlayer))
     *      {
     *          res += 1f;
     *          return res += checkDiagonalDown(col - 1, row + 1, increment);
     *      }
     *
     *  }
     *  if (!increment && column < VerticalSize && row > 0)
     *  {
     *      if (fields[column + 1][row - 1].GetPlayer().Equals(currentPlayer))
     *      {
     *          res += 1f;
     *          return res += checkDiagonalDown(col + 1, row - 1, increment);
     *      }
     *  }
     *  return res;
     * }
     */


    private void togglePlayer()
    {
        PlayerInterface tmpPlayer = waitingPlayer;

        waitingPlayer = currentPlayer;
        currentPlayer = tmpPlayer;
    }
예제 #20
0
    /// <summary>
    /// 与玩家发生碰撞
    /// </summary>
    protected virtual void CollidedByPlayer()
    {
        CharacterBase player = PlayerInterface.GetInstance().GetCharacter();

        player.BeingHit();
        _collidedByPlayer?.Invoke(this, player);
    }
예제 #21
0
 private void NewGame()
 {
     timer1.Interval   = 1000 / Convert.ToInt32(numericUpDown1.Value);
     connection        = null;
     table             = new Table();
     selectedCardIndex = -1;
     if (comboBox2.SelectedItem.ToString() == "Network Player")
     {
         if (radioButton1.Checked)                // We are host
         {
             TcpListener serverSocket = new TcpListener(Convert.ToInt32(textBox2.Text));
             serverSocket.Start();
             connection = serverSocket.AcceptTcpClient();
             serverSocket.Stop();
         }
         else
         {
             connection = new TcpClient(textBox1.Text, Convert.ToInt32(textBox2.Text));
         }
         connection.ReceiveTimeout = Int32.MaxValue;
     }
     player1       = GeneratePlayer(comboBox1.SelectedItem.ToString(), false);
     player2       = GeneratePlayer(comboBox2.SelectedItem.ToString(), true);
     currentPlayer = player1;
     if (radioButton2.Checked && connection != null)
     {
         currentPlayer = player2;
     }
 }
예제 #22
0
 public override void Deactivate(PlayerInterface player)
 {
     connectedPlayer = null;
     player.SetShipInterface(null);
     busy = false;
     print("DeActivate");
 }
예제 #23
0
 public bool CheckForGameOver()
 {
     if (currentPlayer == null)
     {
         return(false);
     }
     if (table.GetNumberOfCards() == 9)
     {
         currentPlayer = null;
         if (connection != null)
         {
             connection.Close();
         }
         timer1.Stop();
         int playerCardsCount = table.GetNumberOfCardsPlayerOwns(false);
         int enemyCardsCount  = table.GetNumberOfCardsPlayerOwns(true);
         if (playerCardsCount > enemyCardsCount)
         {
             MessageBox.Show("You win!");
         }
         else
         {
             MessageBox.Show("You lose!");
         }
         panel1.Visible = true;
         Refresh();
         return(true);
     }
     return(false);
 }
예제 #24
0
    void OnCollisionEnter(Collision col)
    {
        if (!collided && col.gameObject.tag == "Hitbox")
        {
            collided = true;
            PlayerInterface  playerInt = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerController> ();
            PlayerController player    = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerController> ();

            /*if (player.attacking && (lane & Lanes.M) != Lanes.None) {
             *      playerInt.BossAttacked (34, Lanes.A);
             * } else if(!player.attacking) {
             *      playerInt.BossAttacked (34, Lanes.A);
             * }*/
            playerInt.BossAttacked(34, Lanes.A);
        }
        else if (!collided && col.gameObject.tag == "Backwall")
        {
            collided = true;
            Rigidbody rb = gameObject.GetComponent <Rigidbody> ();

            Vector3 dir = new Vector3(Random.Range(-0.4f, 0.4f), Random.Range(-0.2f, 0.2f), Random.Range(0.0f, 1.0f));
            dir.Normalize();

            rb.AddForce(dir * 100.0f);
        }
    }
        public void RenderCamera(HvrRender hvrRender, HVRViewportInterface viewport, bool resizedViewport = false)
        {
            // If the Unity viewport has been resized and an OpenGL renderer
            // is in use then Unity will have recreated the main OpenGL
            // context so all framebuffer and vertex attribute objects that
            // are not shareable need to be destroyed and recreated.
            //
            // The extra call to `PlayerInterface.PreRender()` in this case is
            // to make sure that the vertex buffers are populated for the
            // render call below to avoid flickering.
            if (resizedViewport)
            {
                StaticInterface.Self().ResetFrameBuffersAndMeshes();
                PlayerInterface.PreRender(SceneInterface.Self().hvrSceneInterface);
                PlayerInterface.PreRender(SceneInterface.Self().hvrSceneInterface);
            }

            Update();
            LateUpdate();

            if (!SceneInterface.Self().sceneHasPreRendered)
            {
                PlayerInterface.PreRender(SceneInterface.Self().hvrSceneInterface);
                SceneInterface.Self().sceneHasPreRendered = true;
            }

            PlayerInterface.Render(SceneInterface.Self().hvrSceneInterface, viewport);
        }
예제 #26
0
    /// <summary>
    /// 设置玩家当前是否可以移动
    /// <para>isMovable </para>
    /// </summary>
    /// <param name="luaState"></param>
    /// <returns></returns>
    public static int SetPlayerIsMovable(ILuaState luaState)
    {
        bool isMovable = luaState.ToBoolean(-1);

        PlayerInterface.GetInstance().GetCharacter().IsMovable = isMovable;
        return(0);
    }
예제 #27
0
 public virtual void Init()
 {
     _instID      = ObjectsPool.GetInstance().GetNewInstanceID();
     _isAvailable = true;
     _curDir      = Consts.DIR_NULL;
     _isExplosive = false;
     if (_tasks == null)
     {
         _tasks = new List <Task>();
     }
     if (_movableObj == null)
     {
         _movableObj = ObjectsPool.GetInstance().GetPoolClassAtPool <MovableObject>();
     }
     _taskCount                     = 0;
     _isWandering                   = false;
     _isInteractive                 = true;
     _onHitFuncRef                  = 0;
     _onEliminateFuncRef            = 0;
     _resistEliminateFlag           = 0;
     _attachmentsCount              = 0;
     _isFollowingMasterContinuously = false;
     _isFollowMasterRotation        = false;
     _player = PlayerInterface.GetInstance().GetCharacter();
 }
예제 #28
0
    public Player() : base(0.3f, 2.0f, 100f)
    {
        _physics.airControl = true;

        _inventory = new ItemContainer[36];

        for (int index = 0; index < _inventory.Length; index++)
        {
            _inventory[index] = new ItemContainer();
        }

        _playerGraphics  = new PlayerGraphics(this);
        _playerInterface = new PlayerInterface(this);

        _pickedItemContainer = inventory[0];

        _playerAttackDamage = new Damage(this);

        Item[] items = Item.GetItemAll();
        for (int index = 0; index < inventorySize; index++)
        {
            if (index >= items.Length)
            {
                break;
            }

            inventory[index].Apply(new ItemStack(items[index], 30));
        }

        CreateCommand();
    }
예제 #29
0
    private void Update()
    {
        if (playerInterface == null)
        {
            playerInterface = GameObject.Find("Player").GetComponent <PlayerInterface>();
        }

        if (Bulle_Box.activeSelf)
        {
            if (Input.GetKeyDown(KeyCode.F))
            {
                Fill_Flag = false;
            }
            if (Input.GetKey(KeyCode.F))
            {
                if (!Fill_Flag)
                {
                    Fill_Image.fillAmount += 0.02f;
                    if (Fill_Image.fillAmount == 1)
                    {
                        Fill_Image.fillAmount = 0;
                        playerInterface.SupplementAmmunition();
                        Fill_Flag = true;
                    }
                }
            }
            if (Input.GetKeyUp(KeyCode.F))
            {
                Fill_Image.fillAmount = 0;
            }
        }
    }
예제 #30
0
    public void Initialize(int skillDamage, Unit target, bool critical, PlayerInterface interfaceRef)
    {
        base.Initialize();

        playerInterface = interfaceRef;
        isCritical      = critical;
        damage          = skillDamage;

        transform.position = target.UnitCollider.bounds.max;
        screenPoint        = Camera.main.WorldToScreenPoint(transform.position);

        if (isCritical)
        {
            lastFontSize = playerInterface.damageLabelStyle.fontSize;
            playerInterface.damageLabelStyle.fontSize += (int)(1.5f * playerInterface.damageLabelStyle.fontSize * floatTime / duration);
            labelSize = playerInterface.damageLabelStyle.CalcSize(new GUIContent(damage.ToString()));
            playerInterface.damageLabelStyle.fontSize = lastFontSize;
        }
        else
        {
            labelSize = playerInterface.damageLabelStyle.CalcSize(new GUIContent(damage.ToString()));
        }

        labelRect = new Rect(screenPoint.x - labelSize.x / 2, Screen.height - screenPoint.y - labelSize.y / 2, labelSize.x, labelSize.x);
    }
예제 #31
0
 void Awake()
 {
     player_interface = this;
 }