Example #1
0
 private void FixedUpdate()
 {
     if (!Logic.Instance.IsGameOver && !Logic.Instance.StayPlayer)
     {
         IsGround = Physics2D.OverlapCircle(CoordinateLegs.position, 0.2f, Ground);
         Move();
         if (InputUI.GetKeyDown(UIKeyCode.FIRE))
         {
             UpSpeed(2);
         }
         if (IsGround)
         {
             JumpForce = basic_jump_force;                 // default jump when player on ground
         }
         if (IsUpSpeed && InputUI.GetKey(UIKeyCode.SPACE) && !IsGround)
         {
             UpJumpForceInAir();
         }
         if (InputUI.GetKeyDown(UIKeyCode.SPACE) && IsGround)
         {
             Jump(JumpForce);
         }
         if ((InputUI.GetKey(UIKeyCode.DOWN) || Input.GetKey(KeyCode.S)) && Logic.Instance.ModePlayer != Mode.LITTLE)
         {
             Sit();
         }
     }
 }
    public void OnDrag(PointerEventData data)
    {
        Vector3 newPos = Vector3.zero;

        if (m_UseX)
        {
            int delta = (int)(data.position.x - startDownPos.x);
            newPos.x = delta;
        }

        if (m_UseY)
        {
            int delta = (int)(data.position.y - startDownPos.y);
            newPos.y = delta;
        }
      

        newPos = Vector3.ClampMagnitude(newPos, MovementRange);

        InputUI inputUI = GameObject.FindGameObjectWithTag("InputUI").GetComponent<InputUI>();

        inputUI.AcceptThrowDelta(newPos);

        pointerPoint.transform.position = newPos + startDownPos;

        UpdateVirtualAxes(pointerPoint.transform.position);
    }
Example #3
0
        public void Start()
        {
            _current = this;

            AllSurvivorsDead    = false;
            AllSurvivorsEscaped = false;
            ExitGatesPowered    = false;

            Trial  = new Trial(5, 5);
            Player = new Survivor("You");
            Player.IsLocalPlayer = true;

            Survivors = new List <Survivor>()
            {
                new Survivor("Nancy"),
                new Survivor("Dwight"),
                new Survivor("Meg"),
                new Survivor("Zaria")
            };

            Killer = new Killer("The Wraith");
            var brain = new Brain(BrainStateType.WANDER);

            brain.Control(Killer);

            Player.AddPerk(new SprintBurstPerk());

            Trial.Spawn(Player);
            Trial.Spawn(Killer);

            foreach (var survivor in Survivors)
            {
                var survivorBrain = new Brain(BrainStateType.WANDER);
                survivorBrain.Control(survivor);
                Trial.Spawn(survivor);
            }

            eventUI   = new EventUI();
            perkUI    = new PerkUI();
            inputUI   = new InputUI();
            minimapUI = new MinimapUI();
            repairUI  = new RepairUI();

            UIManager.Add(eventUI);
            UIManager.Add(perkUI);
            UIManager.Add(inputUI);
            UIManager.Add(minimapUI);
            UIManager.Add(repairUI);

            repairUI.Visible = false;

            inputUI.Input.OnInput = (text) =>
            {
                ProcessInput(text);
            };

            GameLoopThread = new Thread(new ThreadStart(Update));
            GameLoopThread.IsBackground = true;
            GameLoopThread.Start();
        }
    public void OnPointerUp(PointerEventData data)
    {
        //print("OnPointerUp()");
        Vector3 delta = Vector3.zero;
        if (m_UseX)
        {
            int x = (int)(data.position.x - startDownPos.x);
            delta.x = x;
        }

        if (m_UseY)
        {
            int y = (int)(data.position.y - startDownPos.y);
            delta.y = y;
        }

        delta = Vector3.ClampMagnitude(delta, MovementRange);

        InputUI inputUI = GameObject.FindGameObjectWithTag("InputUI").GetComponent<InputUI>();
        inputUI.AcceptThrowDelta(delta);
        inputUI.ReleaseThrow();

        pointerPoint.transform.position = startDownPos;
        UpdateVirtualAxes(startDownPos);

        pointerBase.GetComponent<Image>().color = passiveColor;
        pointerPoint.GetComponent<Image>().color = passiveColor;
    }
Example #5
0
    public void AttachInputToUI()
    {
        //print("Attaching Input To UI");
        inputUIObj = GameObject.FindGameObjectWithTag("InputUI");
        inputUI    = inputUIObj.GetComponent <InputUI>();
        inputUI.AttachInputManager(this);

        inputUI.enableCatchingControls();
    }
Example #6
0
 private void Drift()
 {
     Flip(InputUI.GetAxis("Horizontal"));
     state.SetInteger("State", (int)State.DRIFT);
     timer_on_drift += Time.deltaTime;
     if (timer_on_drift >= time_on_drift)
     {
         IsDriftAvailable = false;
         timer_on_drift   = 0;
     }
 }
Example #7
0
 private void Awake()
 {
     if (Instance)
     {
         Destroy(this);
     }
     else
     {
         Instance = this;
     }
 }
Example #8
0
 private void UpJumpForceInAir()
 {
     if (JumpForce <= max_jump_force)
     {
         JumpForce           += 2;
         body_player.velocity = new Vector2(body_player.velocity.x, JumpForce / 2);
     }
     if (InputUI.GetKeyUp(UIKeyCode.SPACE))
     {
         IsUpSpeed = false;
     }
 }
Example #9
0
    private GameManager gameManager;                    // Game manager reference
    #endregion

    #region Main Methods
    public void AwakeBehaviour(Character player)
    {
        // Get references
        gameManager = GameManager.Instance;
        playerChar  = player;

        // Initialize values
        brilliantMat = pilarRenderer.materials[index];
        shadowColor  = brilliantMat.GetColor("_SColor");
        rimColor     = brilliantMat.GetColor("_RimColor");

        // Instantiate interact game object
        GameObject newObject = (GameObject)Instantiate(interactPrefab, Vector3.zero, Quaternion.identity);

        // Get input UI reference from new object
        InputUI newUI = newObject.GetComponent <InputUI>();

        // Add new input UI reference to interface manager inputs list
        interfaceManager.Inputs.Add(newUI);

        // Initialize new input UI reference
        newUI.AwakeBehaviour();

        // Set new interact object parent to the interact root transform
        newObject.transform.SetParent(interactRoot, false);

        // Get transform and rect transform references from new object
        interactUI   = newObject.transform;
        interactRect = newObject.GetComponent <RectTransform>();
        interactRect.anchoredPosition = Vector2.zero;

        // Disable interact game object by default
        interactUI.gameObject.SetActive(false);

        if (lineRenderer)
        {
            // Initialize line renderer positions and get values
            linePositions = new Vector3[lineRenderer.transform.childCount];
            for (int i = 0; i < linePositions.Length; i++)
            {
                linePositions[i] = lineRenderer.transform.GetChild(i).position;
            }

            // Initialize line renderer
            lineRenderer.useWorldSpace = true;
            lineRenderer.SetVertexCount(linePositions.Length);
            lineRenderer.SetPositions(linePositions);
            laserEnd.position = linePositions[1];
        }
    }
Example #10
0
 private void FixedUpdate()
 {
     if (InputUI.GetKeyDown(UIKeyCode.FIRE) && Logic.Instance.ModePlayer == Mode.FIRE && CountFireball < max_fireball)
     {
         Fire();
     }
     if (IsShoot)
     {
         shoot_timer += Time.deltaTime;
         if (shoot_timer >= shoot_time)
         {
             IsShoot     = false;
             shoot_timer = 0;
         }
     }
 }
Example #11
0
 private void OnTriggerStay2D(Collider2D collision)
 {
     if (collision.gameObject.tag == "Secret" && !isTeleport)
     {
         if (InputUI.GetKeyDown(UIKeyCode.DOWN))
         {
             isTeleport = true;
             direction  = Direction.DOWN;
             GetComponent <Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezeAll;
             Logic.Instance.BackgroundMain.Stop();
             Logic.Instance.PipeAndDownLevel.Play();
             Invoke("TeleportToSecret", time_on_direction);
             Invoke("PlayBackgroundSecret", time_on_direction);
         }
     }
 }
Example #12
0
 private void Move()
 {
     if (!IsDriftAvailable && IsGround && !Shoot.IsShoot)
     {
         if (InputUI.GetAxis("Horizontal") != 0)
         {
             Flip(InputUI.GetAxis("Horizontal"));
             state.SetInteger("State", (int)State.RUN);
         }
         else
         {
             Speed = basic_speed;
             state.SetInteger("State", (int)State.IDLE);
         }
     }
     body_player.AddForce(new Vector2(InputUI.GetAxis("Horizontal") * Speed, body_player.velocity.y));
     body_player.AddForce(new Vector2(Input.GetAxis("Horizontal") * Speed, body_player.velocity.y));
 }
Example #13
0
    private float vibrationCounter;                     // Gamepad vibration time counter
    #endregion

    #region Main Methods
    public void AwakeBehaviour(Character player)
    {
        // Get references
        gameManager = GameManager.Instance;
        playerChar  = player;

        // Initialize values
        canInvoke = true;
        Renderer[] renderers = GetComponentsInChildren <Renderer>();
        materials = new Material[renderers.Length];

        // Get references
        for (int i = 0; i < renderers.Length; i++)
        {
            materials[i] = renderers[i].material;
        }

        // Instantiate interact game object
        GameObject newObject = (GameObject)Instantiate(interactPrefab, Vector3.zero, Quaternion.identity);

        // Get input UI reference from new object
        InputUI newUI = newObject.GetComponent <InputUI>();

        // Add new input UI reference to interface manager inputs list
        interfaceManager.Inputs.Add(newUI);

        // Initialize new input UI reference
        newUI.AwakeBehaviour();

        // Set new interact object parent to the interact root transform
        newObject.transform.SetParent(interactRoot, false);

        // Get transform and rect transform references from new object
        interactUI   = newObject.transform;
        interactRect = newObject.GetComponent <RectTransform>();
        interactRect.anchoredPosition = Vector2.zero;

        // Disable interact game object by default
        interactUI.gameObject.SetActive(false);
    }
Example #14
0
 private void Update()
 {
     if (Logic.Instance.IsGameOver)         // time to restart lvl, if mario is dead
     {
         agony_timer += Time.deltaTime;
         if (agony_timer >= agony_time)
         {
             Logic.Instance.TransitToCurrentLevel();
         }
     }
     else
     {
         #region DriftCrutch
         // if direction change, then animation of drift is on
         if (IsDriftAvailable && InputUI.GetAxis("Horizontal") != last_direction && InputUI.GetAxis("Horizontal") != 0)
         {
             Drift();
         }
         else if (IsDriftAvailable && body_player.velocity.x > -0.25f && body_player.velocity.x < 0.25f)
         {
             IsDriftAvailable = false;
         }
         #endregion
         // if player in motion, then the counter is accumulated for possible the drift
         if (InputUI.GetAxis("Horizontal") != 0 && !IsDriftAvailable)
         {
             drift_timer += Time.deltaTime;
             if (drift_timer >= drift_time)
             {
                 last_direction   = InputUI.GetAxis("Horizontal");
                 IsDriftAvailable = true;
                 drift_timer      = 0;
             }
         }
     }
 }
Example #15
0
        private void gridControl_View_CellDoubleClick(object sender, DataGridViewCellEventArgs e)   // 그리드뷰 더블클릭 쓰기
        {
            int row = Grid.CurrentCell.RowIndex;
            int col = Grid.CurrentCell.ColumnIndex;

            if (state == 1)
            {
                if (e.ColumnIndex > 0)         // column : 15 ~ 0
                {
                    //18~21열
                    if (e.ColumnIndex >= 17)     // Column :  HIGH ~ ASCII
                    {
                        string selectAddr = Grid[e.ColumnIndex, 0].Value.ToString();
                        string dataType   = string.Empty;
                        if (string.IsNullOrEmpty(selectAddr))
                        {
                            return;
                        }

                        int addressNo = row;

                        if (e.ColumnIndex == 17)
                        {
                            dataType = PLCSetDataType.HIGHT_BYTE;                           // HIGH    (08 ~ 15 비트)
                        }
                        else if (e.ColumnIndex == 18)
                        {
                            dataType = PLCSetDataType.LOW_BYTE;                             // LOW     (00 ~ 07 비트)
                        }
                        else if (e.ColumnIndex == 19)
                        {
                            dataType = PLCSetDataType.INTEGER;                              // ALL
                        }
                        else if (e.ColumnIndex == 20)
                        {
                            dataType = PLCSetDataType.ASCII;                                 // ASCII
                        }
                        InputUI form = new InputUI(dataType, iSelectedRegister, iSelectedAddress + addressNo, this);
                        form.ShowDialog();
                    }
                    //1~16열
                    else
                    {
                        Grid[col, row].Value = 1;       // 선택한 셀 데이터 값 1

                        int tmp = 0;
                        try
                        {
                            tmp = int.Parse(Grid[e.ColumnIndex, e.RowIndex].Value.ToString());  // 문자열을 숫자로 변환 함수
                        }


                        catch
                        {
                            return;
                        }

                        CDataSet ds      = new CDataSet(2);
                        byte[]   tmpbyte = new byte[2];
                        tmpbyte = PLCManager.ReadForByte(Device_Def.SearchDeviceCode(Device_Def.Device), iSelectedAddress + (e.RowIndex), 2);     // 바이트로 읽기

                        ds.SetSourceByteArray(0, tmpbyte);
                        ds.SetSource(16 - e.ColumnIndex, (ds.GetSource(16 - e.ColumnIndex) == true) ? false : true);

                        PLCManager.WriteForByte(Device_Def.SearchDeviceCode(Device_Def.Device), iSelectedAddress + (e.RowIndex), ds.GetSource());  // 바이트로 쓰기
                    }
                }



                RefreshDisplayPLCData();
            }

            if (state == 2)
            {
                if (e.ColumnIndex > 0)         // column : 15 ~ 0
                {
                    //18~21열
                    if (e.ColumnIndex >= 17)     // Column :  HIGH ~ ASCII
                    {
                        string selectAddr = Grid[e.ColumnIndex, 0].Value.ToString();
                        string dataType   = string.Empty;
                        if (string.IsNullOrEmpty(selectAddr))
                        {
                            return;
                        }

                        int addressNo = row;

                        if (e.ColumnIndex == 17)
                        {
                            dataType = PLCSetDataType.HIGHT_BYTE;                           // HIGH    (08 ~ 15 비트)
                        }
                        else if (e.ColumnIndex == 18)
                        {
                            dataType = PLCSetDataType.LOW_BYTE;                             // LOW     (00 ~ 07 비트)
                        }
                        else if (e.ColumnIndex == 19)
                        {
                            dataType = PLCSetDataType.INTEGER;                              // ALL
                        }
                        else if (e.ColumnIndex == 20)
                        {
                            dataType = PLCSetDataType.ASCII;                                 // ASCII
                        }
                        InputUI form = new InputUI(dataType, iSelectedRegister, iSelectedAddress + addressNo, this);
                        form.ShowDialog();

                        //RefreshDisplayPLCData();
                    }
                    else
                    {
                        Grid[col, row].Value = 1;
                        CDataSet ds      = new CDataSet(2);
                        byte[]   tmpbyte = new byte[2];

                        tmpbyte = PLCManager.ReadForByte(Device_Def.SearchDeviceCode(Device_Def.Device), iSelectedAddress + (e.RowIndex), 2);     // 바이트로 읽기

                        ds.SetSourceByteArray(0, tmpbyte);
                        ds.SetSource(16 - e.ColumnIndex, (ds.GetSource(16 - e.ColumnIndex) == true) ? false : true);

                        PLCManager.WriteForByte(Device_Def.SearchDeviceCode(Device_Def.Device), iSelectedAddress + (e.RowIndex), ds.GetSource());
                        wSendFrame.MakeWriteFrame(Device_Def.CMD_WORD_UNIT, Device_Def.SearchDeviceCode(Device), ds.GetSource(), iSelectedAddress + (e.RowIndex), 1);

                        if (CL.SendMessage(wSendFrame) == false)
                        {
                        }
                    }
                }
                DisplayGridData();
            }
        }