Exemplo n.º 1
0
 public static void ResetCursor()
 {
     UIManager.Instance.OnResetCursor();
     CurrentCursorMode = CursorMode.Select;
     BlueprintCursorFollower.EndCursorBlueprintFollow();
     RemoveKeyAction(KeyCode.Mouse1);
     SetKeyAction(KeyCode.Mouse0, new IActions.Action_TrySelect());
     SetSelectedBuilding(null);
     // SetKeyAction(KeyCode.Escape, new IActions.Action_ResetCursor());
 }
Exemplo n.º 2
0
    void Update()
    {
        for (var i = 0; i < DirtyKeyCodeList.Count - 1; i++)
        {
            DirtyKeyCodeList.RemoveAt(i);
            KeyActionDictionary.Remove(DirtyKeyCodeList[i]);
        }
        if (EventSystem.current.IsPointerOverGameObject())
        {
            return;
        }

        BlueprintCursorFollower.Update();
        if (Input.GetMouseButtonUp(0))
        {
            if (KeyActionDictionary.ContainsKey(KeyCode.Mouse0))
            {
                // Debug.Log($"Mouse0");

                AudioManager.PlaySound("click");
                KeyActionDictionary[KeyCode.Mouse0].Execute();
            }
        }
        if (Input.GetMouseButtonUp(1))
        {
            if (KeyActionDictionary.ContainsKey(KeyCode.Mouse1))
            {
                AudioManager.PlaySound("click");
                KeyActionDictionary[KeyCode.Mouse1].Execute();
            }
        }
        if (Input.GetMouseButtonUp(2))
        {
            if (KeyActionDictionary.ContainsKey(KeyCode.Mouse2))
            {
                AudioManager.PlaySound("click");
                KeyActionDictionary[KeyCode.Mouse2].Execute();
            }
        }

        // foreach (var item in KeyActionDictionary)
        // {
        //     if (item.Key == KeyCode.Mouse0 || item.Key == KeyCode.Mouse1 || item.Key == KeyCode.Mouse2) continue;
        //     if (Input.GetKeyUp(item.Key))
        //     {
        //         AudioManager.PlaySound("click");
        //         KeyActionDictionary[item.Key].Execute();
        //     }
        // }
    }
Exemplo n.º 3
0
    public void OnBuildClicked(int id)
    {
        Debug.Log("Build " + id);
        if (InputManager.CurrentCursorMode == InputManager.CursorMode.Build)
        {
            InputManager.ResetCursor();
        }

        Sprite s     = DataContainer.Instance.ConcreteGhostSprite;
        int    fMode = 0;

        switch (id)
        {
        case 0:     //probe
            if (!GameManager.Instance.SetBananaBalance(-price_probe, true))
            {
                return;
            }

            ShowBuildHint($"<color=red> One time use </color>orbital dropped probe. Reveals bananas. Temporarily scares off monkeys");
            hintPinned = true;
            s          = DataContainer.Instance.TargetSprite;
            fMode      = 3;
            InputManager.SetKeyAction(KeyCode.Mouse0, new IActions.Action_DropProbe());

            break;

        case 1:     //extractor
            if (!GameManager.Instance.SetBananaBalance(-price_ext, true))
            {
                return;
            }

            ShowBuildHint($"Extracts bananas from nature. Removes banana trees when they deplete. Must be fueled. <color=orange>Caution: </color> monkeys will steal bananas. pick up regularly with truck",
                          $"Must be placed on concrete");
            hintPinned = true;

            s     = DataContainer.Instance.ExtractorGhostSprite;
            fMode = 1;
            InputManager.SetKeyAction(KeyCode.Mouse0, new IActions.Action_PlaceExtractor());

            break;

        case 2:     //oilrig
            if (!GameManager.Instance.SetBananaBalance(-price_ref, true))
            {
                return;
            }

            ShowBuildHint($"Produces banana oil from bananas. Uses monkeys as slave labour. <color=orange>Caution: </color> monkeys will escape regularly", $"Must be placed on concrete");
            hintPinned = true;
            InputManager.SetKeyAction(KeyCode.Mouse0, new IActions.Action_PlaceRefinery());

            s     = DataContainer.Instance.OilGhostSprite;
            fMode = 1;

            break;

        case 3:     //trap
            if (!GameManager.Instance.SetBananaBalance(-price_trap, true))
            {
                return;
            }

            ShowBuildHint($"Traps monkeys as they stroll by. <color=orange>Caution: </color> monkeys will escape regularly, use truck to collect", $"Must be placed on concrete");
            hintPinned = true;

            s     = DataContainer.Instance.TrapGhostSprite;
            fMode = 1;

            break;

        case 4:     //concrete
            if (!GameManager.Instance.SetBananaBalance(-price_conc, true))
            {
                return;
            }

            ShowBuildHint($"Concrete road. used as a base for all your industrialisation efforts.\n <color=red> Say NO to rainforests! </color>", $"Must be placed ajacent to another road");
            hintPinned = true;
            InputManager.SetKeyAction(KeyCode.Mouse0, new IActions.Action_PlaceRoad());

            s     = DataContainer.Instance.ConcreteGhostSprite;
            fMode = 2;

            break;

        case 5:     // truck
            if (!GameManager.Instance.SetBananaBalance(-price_truck, true))
            {
                return;
            }

            // ShowBuildHint($"Just a truck. Can be used to transport bananas and/or monkeys. Semi-intelligent driver (monkey?)", $"Drives on concrete");

            s     = DataContainer.Instance.ProbeGhostSprite;
            fMode = 4;
            GameManager.Instance.SetBananaBalance(-price_truck);

            break;

        case 6:
            ShowBuildHint($"Bulldoze for half price", $"");
            hintPinned = true;
            InputManager.SetKeyAction(KeyCode.Mouse0, new IActions.Action_Bulldoze());

            s     = DataContainer.Instance.ConcreteGhostSprite;
            fMode = 3;
            break;
        }
        Debug.Log("Build confirm " + id);
        InputManager.CurrentCursorMode = InputManager.CursorMode.Build;

        BlueprintCursorFollower.StartCursorBlueprintFollow(s, fMode);
    }