コード例 #1
0
        /// <summary>
        /// this updates the gun.
        /// </summary>
        /// <param name="elapsedTime"></param>
        public override void Update(float elapsedTime)
        {
            dgt1 += elapsedTime;
            dgt2 += elapsedTime;

            if (dgt1 < .5f && dgt1 > .4f)
            {
                cs = CCState.close;
            }
            if (dgt1 > .75f && state == MBState.Full)
            {
                ScrollingShooterGame.GameObjectManager.CreateProjectile(ProjectileType.EBullet, position);
                dgt1 = 0;
                cs   = CCState.fire;
            }
            if (dgt1 > .66f && state == MBState.Half)
            {
                ScrollingShooterGame.GameObjectManager.CreateProjectile(ProjectileType.EBullet, position);
                dgt1 = 0;
                cs   = CCState.fire;
            }
            if (dgt2 > .76f && state == MBState.Full)
            {
                ScrollingShooterGame.GameObjectManager.CreateProjectile(ProjectileType.EBullet, position);
                dgt2 = 0;
                cs   = CCState.none;
            }
            if (dgt2 > .67f && state == MBState.Half)
            {
                ScrollingShooterGame.GameObjectManager.CreateProjectile(ProjectileType.EBullet, position);
                dgt2 = 0;
                cs   = CCState.none;
            }
        }
コード例 #2
0
        /// <summary>
        /// This creates the gun on the boss.
        /// </summary>
        /// <param name="id"></param>
        /// <param name="content"></param>
        /// <param name="position"></param>
        public MBCloseC(uint id, ContentManager content, Vector2 position)
            : base(id)
        {
            this.position = position;
            Health = 600;

            spritesheet = content.Load<Texture2D>("Spritesheets/newshb.shp.000000");

            spriteBounds[(int)CCState.none].X = 0;
            spriteBounds[(int)CCState.none].Y = 140;
            spriteBounds[(int)CCState.none].Width = 48;
            spriteBounds[(int)CCState.none].Height = 28;

            spriteBounds[(int)CCState.close].X = 0;
            spriteBounds[(int)CCState.close].Y = 168;
            spriteBounds[(int)CCState.close].Width = 48;
            spriteBounds[(int)CCState.close].Height = 28;

            spriteBounds[(int)CCState.fire].X = 0;
            spriteBounds[(int)CCState.fire].Y = 196;
            spriteBounds[(int)CCState.fire].Width = 48;
            spriteBounds[(int)CCState.fire].Height = 28;

            state = MBState.Full;
            cs = CCState.none;
        }
コード例 #3
0
    /// <summary>
    /// Sets the current CCState and renders all displayed menus for this state
    /// </summary>
    void SetCCState(CCState newState, bool updateMenus)
    {
        //Begin state enable stuff

        //Begin state disable stuff
        if (newState != CCState.Selecting)
        {
            CC_Selectable.CancelSelect();
        }

        CC_Menu CreationMenu = GetMenuByName("CreationMenu");

        if (CreationMenu != null)
        {
            CreationMenu.SetEnabled(false);
        }

        CC_Menu windowManagerMenu = GetMenuByName("WindowManagerMenu");

        if (windowManagerMenu != null)
        {
            windowManagerMenu.SetEnabled(false);
        }

        CC_UISelectionManager._instance.ChangeCCState(newState);

        backgroundHandler.Disable();

        //Menu rendering
        if (updateMenus)
        {
            UpdateMenus(newState);
        }
        currState = newState;
    }
コード例 #4
0
        /// <summary>
        /// This creates the gun on the boss.
        /// </summary>
        /// <param name="id"></param>
        /// <param name="content"></param>
        /// <param name="position"></param>
        public MBCloseC(uint id, ContentManager content, Vector2 position)
            : base(id)
        {
            this.position = position;
            Health        = 600;

            spritesheet = content.Load <Texture2D>("Spritesheets/newshb.shp.000000");

            spriteBounds[(int)CCState.none].X      = 0;
            spriteBounds[(int)CCState.none].Y      = 140;
            spriteBounds[(int)CCState.none].Width  = 48;
            spriteBounds[(int)CCState.none].Height = 28;

            spriteBounds[(int)CCState.close].X      = 0;
            spriteBounds[(int)CCState.close].Y      = 168;
            spriteBounds[(int)CCState.close].Width  = 48;
            spriteBounds[(int)CCState.close].Height = 28;

            spriteBounds[(int)CCState.fire].X      = 0;
            spriteBounds[(int)CCState.fire].Y      = 196;
            spriteBounds[(int)CCState.fire].Width  = 48;
            spriteBounds[(int)CCState.fire].Height = 28;

            state = MBState.Full;
            cs    = CCState.none;
        }
コード例 #5
0
 /// <summary>
 /// Creates a base CC_Menu initializes it and adds it to the menu list
 /// </summary>
 public CC_Menu CreateNewCC_Menu(GameObject panelPrefab, CCState[] renderStates, string menuName)
 {
     //GameObject g = new GameObject();
     //CC_Menu menu = g.AddComponent<CC_Menu>();
     CC_Menu menu = ScriptableObject.CreateInstance<CC_Menu>();
     menu.Initialize(menuPanelPrefab, renderStates, menuName);
     menus.Add(menu);
     return menu;
 }
コード例 #6
0
    public override void UpdateContextInfo()
    {
        List <RaycastHit> raycastHits = new List <RaycastHit>(Physics.SphereCastAll(m_CapsuleTransform.GetPosition(), m_Radius - m_GroundedMargin, -m_CapsuleTransform.GetUpDirection(), (m_CapsuleTransform.GetLength() * 0.5f) + m_GroundedCheckDistance + m_GroundedMargin, m_LayerMask));

        m_State.UpdateGroundedInfo(raycastHits);
        List <RaycastHit> rightCastResults = CCState.CorrectCapsuleCastAll(GetDownCenter(true), GetUpCenter(true), GetRadius() - m_SideCastMargin, m_CapsuleTransform.GetRightDirection(), m_SideCastDistance + m_SideCastMargin, m_LayerMask);
        List <RaycastHit> leftCastResults  = CCState.CorrectCapsuleCastAll(GetDownCenter(true), GetUpCenter(true), GetRadius() - m_SideCastMargin, -m_CapsuleTransform.GetRightDirection(), m_SideCastDistance + m_SideCastMargin, m_LayerMask);

        m_State.UpdateSideCastInfo(leftCastResults, rightCastResults);
        m_State.UpdateEdgeCastInfo();
    }
コード例 #7
0
 private void HandleEstablished(ChaincodeMessage message)
 {
     if (message.Type == ChaincodeMessage.Types.Type.Ready)
     {
         State = CCState.READY;
         logger.Debug($"[{message.Txid,-8}s] Received READY: ready for invocations");
     }
     else
     {
         logger.Warning($"[{message.Txid,-8}s] Received {message.Type}: cannot handle");
     }
 }
コード例 #8
0
 private void HandleCreated(ChaincodeMessage message)
 {
     if (message.Type == ChaincodeMessage.Types.Type.Registered)
     {
         State = CCState.ESTABLISHED;
         logger.Debug($"[{message.Txid,-8}s] Received REGISTERED: moving to established state");
     }
     else
     {
         logger.Warning($"[{message.Txid,-8}s] Received {message.Type}: cannot handle");
     }
 }
コード例 #9
0
ファイル: CapsuleTransform.cs プロジェクト: AdlanSADOU/EPIJAM
    public bool CanMove(Vector3 a_Movement, bool a_UseMargin = false)
    {
        float   distanceToTravel = a_Movement.magnitude + m_CapsuleCollider.GetMovementCapsuleCastMargin();
        Vector3 direction        = a_Movement.normalized;
        Vector3 margin           = -direction *m_CapsuleCollider.GetMovementCapsuleCastMargin();

        float radius = m_CapsuleCollider.GetRadius();

        if (a_UseMargin)
        {
            radius -= m_CapsuleCollider.GetOptionalMoveCastMargin();
        }
        return(!CCState.CorrectCapsuleCast(GetDownCenter() + margin, GetUpCenter() + margin, radius, direction, distanceToTravel, m_CapsuleCollider.GetLayerMask()));
    }
コード例 #10
0
    /// <summary>
    /// Updates the menus positions given a new state
    /// </summary>
    public void UpdateMenus(CCState newState)
    {
        int renderCount = 0;

        for (int i = 0; i < menus.Count; i++)
        {
            CC_Menu m = menus [i];
            if (m.isEnabled() && m.renderStates.Contains(newState))
            {
                m.StartRender();
                m.SetPosition(renderCount);
                renderCount++;
            }
            else
            {
                m.StopRender();
            }
        }
    }
コード例 #11
0
 //Overload using default menu panel prefab
 public CC_Menu CreateNewCC_Menu(CCState[] renderStates, string menuName)
 {
     return CreateNewCC_Menu(menuPanelPrefab, renderStates, menuName);
 }
コード例 #12
0
 void SetCCState(CCState newState)
 {
     SetCCState(newState, true);
 }
コード例 #13
0
 void SetCCState(CCState newState)
 {
     SetCCState(newState, true);
 }
コード例 #14
0
    /// <summary>
    /// Sets the current CCState and renders all displayed menus for this state
    /// </summary>
    void SetCCState(CCState newState, bool updateMenus)
    {
        //Begin state enable stuff

        //Begin state disable stuff
        if (newState != CCState.Selecting)
            CC_Selectable.CancelSelect();

        CC_Menu CreationMenu = GetMenuByName("CreationMenu");
        if (CreationMenu != null)
            CreationMenu.SetEnabled(false);

        CC_Menu windowManagerMenu = GetMenuByName("WindowManagerMenu");
        if (windowManagerMenu != null)
            windowManagerMenu.SetEnabled(false);

        CC_UISelectionManager._instance.ChangeCCState(newState);

        backgroundHandler.Disable();

        //Menu rendering
        if (updateMenus)
            UpdateMenus(newState);
        currState = newState;
    }
コード例 #15
0
 /// <summary>
 /// Updates the menus positions given a new state
 /// </summary>
 public void UpdateMenus(CCState newState)
 {
     int renderCount = 0;
     for (int i = 0; i < menus.Count; i++) {
         CC_Menu m = menus [i];
         if (m.isEnabled () && m.renderStates.Contains (newState)) {
             m.StartRender ();
             m.SetPosition (renderCount);
             renderCount++;
         } else m.StopRender ();
     }
 }
コード例 #16
0
    //Moves the collider with the current update velocity unti it hits something. Resolves the collision with position and velocity, then tries again.
    //Max iteration count to prevent infinite loop
    void TryMove(Vector3 a_Velocity, ref Vector2 o_PureVel)
    {
        for (int iteration = 0; iteration < 15; iteration++)
        {
            float   distanceToTravel = a_Velocity.magnitude + m_MovementCapsuleCastMargin;
            float   shortestDistance = distanceToTravel;
            int     shortestHitIndex = 0;
            Vector3 direction        = a_Velocity.normalized;
            Vector3 margin           = -direction * m_MovementCapsuleCastMargin;

            List <RaycastHit> hits = CCState.CorrectCapsuleCastAll(GetDownCenter() + margin, GetUpCenter() + margin, m_Radius, direction, distanceToTravel, m_LayerMask);

            bool blocked = false;
            for (int i = hits.Count - 1; i >= 0; i--)
            {
                float dot = Vector3.Dot(a_Velocity, hits[i].normal);
                if (dot >= 0)//Perpendicular or not blocking (relative velocity?)
                {
                    continue;
                }
                if (hits[i].distance < shortestDistance && hits[i].distance > 0 && hits[i].distance >= m_MovementCapsuleCastMargin * 0.9f)
                {
                    shortestDistance = hits[i].distance;
                    shortestHitIndex = i;
                    blocked          = true;
                }
            }
            distanceToTravel = shortestDistance - m_MovementCapsuleCastMargin;
            m_CapsuleTransform.Move(direction * distanceToTravel);
            if (!blocked)
            {
                break;
            }
            else//Reorient, try moving again, correct velocity
            {
                CapsuleCollisionOccurrance collision = new CapsuleCollisionOccurrance();
                collision.m_Point                = hits[shortestHitIndex].point;
                collision.m_Normal               = hits[shortestHitIndex].normal;
                collision.m_Transform            = hits[shortestHitIndex].transform;
                collision.m_IncomingVelocity     = a_Velocity;
                collision.m_IncomingVelocityPure = o_PureVel;

                a_Velocity -= direction * distanceToTravel;

                Vector3 normal   = hits[shortestHitIndex].normal;
                Vector3 aligned  = (new Vector3(normal.y, -normal.x, 0)).normalized;
                float   alignDot = Vector3.Dot(a_Velocity, aligned);
                a_Velocity = aligned * alignDot;
                Vector2 pureAligned = aligned;
                alignDot  = Vector2.Dot(o_PureVel, pureAligned);
                o_PureVel = pureAligned * alignDot;

                collision.m_OutgoingVelocity     = a_Velocity;
                collision.m_OutgoingVelocityPure = o_PureVel;
                collision.m_VelocityLoss         = collision.m_IncomingVelocity - collision.m_OutgoingVelocity;
                collision.m_VelocityLossPure     = collision.m_IncomingVelocityPure - collision.m_OutgoingVelocityPure;
                m_Collisions.Add(collision);
            }
            //Escape when the leftover velocity isn't worthwhile
            if (a_Velocity.magnitude <= m_MinimumViableVelocity)
            {
                break;
            }
        }
    }
コード例 #17
0
        /// <summary>
        /// this updates the gun.
        /// </summary>
        /// <param name="elapsedTime"></param>
        public override void Update(float elapsedTime)
        {
            dgt1 += elapsedTime;
            dgt2 += elapsedTime;

            if (dgt1 < .5f && dgt1 > .4f)
            {
                cs = CCState.close;
            }
            if (dgt1 > .75f && state == MBState.Full)
            {
                ScrollingShooterGame.GameObjectManager.CreateProjectile(ProjectileType.EBullet, position);
                dgt1 = 0;
                cs = CCState.fire;
            }
            if (dgt1 > .66f && state == MBState.Half)
            {
                ScrollingShooterGame.GameObjectManager.CreateProjectile(ProjectileType.EBullet, position);
                dgt1 = 0;
                cs = CCState.fire;
            }
            if (dgt2 > .76f && state == MBState.Full)
            {
                ScrollingShooterGame.GameObjectManager.CreateProjectile(ProjectileType.EBullet, position);
                dgt2 = 0;
                cs = CCState.none;
            }
            if (dgt2 > .67f && state == MBState.Half)
            {
                ScrollingShooterGame.GameObjectManager.CreateProjectile(ProjectileType.EBullet, position);
                dgt2 = 0;
                cs = CCState.none;
            }
        }