Beispiel #1
0
 void OnRepairDone()
 {
     Debug.Log("OnUseDone");
     isUsing = false;
     animator.SetTrigger("repairDone");
     DoToolHolder(false);
     characterMovement.LockMovement(false);
     machineUsed = null;
 }
 public override void OnInspectorGUI()
 {
     base.OnInspectorGUI();
     if (GUILayout.Button("Decay Machine"))
     {
         Machine_Controller controller = (Machine_Controller)target;
         controller.DecayCondition();
     }
 }
Beispiel #3
0
 public bool AddMachine(Machine_Controller newMachine)
 {
     if (machine_controller != null)
     {
         return(false);
     }
     machine_controller = newMachine;
     return(true);
 }
Beispiel #4
0
 void TryRepairMachine(Machine_Controller machine)
 {
     if (isUsing == true)
     {
         return;
     }
     machineUsed = machine;
     DoToolHolder(true);
     animator.SetTrigger("repair");
     characterMovement.LockMovement(true);
     machineUsed.TryRepair(OnRepairDone);
 }
Beispiel #5
0
    public string GetMachineID(Machine_Controller machine_Controller)
    {
        if (machine_Controller == null)
        {
            return(string.Empty);
        }
        if (machine_Controller.machine == null)
        {
            return(string.Empty);
        }
        if (machine_Controller.baseTile == null)
        {
            return(string.Empty);
        }
        string id = machine_Controller.machine.name;

        id += machine_Controller.baseTile.X + "_" + machine_Controller.baseTile.Y;
        return(id);
    }
Beispiel #6
0
    public void StartRepairGame(Machine_Controller _machine)
    {
        if (miniGame_Repair.gameObject.activeSelf == true)
        {
            return;
        }
        current_machine = _machine;
        if (current_machine == null)
        {
            return;
        }

        Vector2 gamePosition = current_machine.transform.position + new Vector3(0, 4, 0);

        miniGame_Repair.gameObject.SetActive(true);
        miniGame_Repair.transform.position = gamePosition;
        miniGame_Repair.Initialize(current_machine.machine.machineCondition, current_machine.machine.repairDifficulty);
        miniGame_Repair.onGameSuccess += OnRepairSuccess;
        miniGame_Repair.onGameFail    += OnRepairFail;
    }
Beispiel #7
0
    public bool AddMachine(Machine_Controller newMachine, Machine machine)
    {
        bool canAdd = false;

        if (newMachine == null)
        {
            return(false);
        }
        if (machine == null)
        {
            return(false);
        }
        switch (machine.systemControlled)
        {
        case ShipSystemType.CargoHold:
            canAdd = shipCargo.AddMachine(newMachine);
            shipCargo.InitCargo(machine.GetStat(StatType.Storage).GetValue());
            break;

        case ShipSystemType.Nav:
            canAdd = shipNavigation.AddMachine(newMachine);
            shipNavigation.InitJumpCapacity(machine.GetStat(StatType.JumpCapacity).GetValue());
            break;

        case ShipSystemType.Propulsion:
            canAdd = shipPropulsion.AddMachine(newMachine);
            break;

        case ShipSystemType.Power:
            canAdd = shipPower.AddMachine(newMachine);
            break;

        case ShipSystemType.Weapons:
            canAdd = shipWeapons.AddMachine(newMachine);
            break;
        }
        return(canAdd);
    }
Beispiel #8
0
    public bool AddMachine(Item machineItem, MachinePrototype prototype, Vector2 machinePosition)
    {
        if (machineItem == null)
        {
            return(false);
        }
        Machine machine = Buildable_Manager.instance.CreateMachineInstance(prototype);

        if (machine == null)
        {
            return(false);
        }
        Debug.Log("Adding " + machine.name);
        GameObject machineGObj = Buildable_Manager.instance.SpawnMachine(machine, machinePosition);

        if (machineGObj == null)
        {
            return(false);
        }

        Machine_Controller mController = machineGObj.GetComponent <Machine_Controller>();

        mController.InitMachine(machineItem, machine, TileManager.instance.GetTile(machinePosition), this);
        if (AddMachine(mController, machine) == true)
        {
            //machine.InitSystems(this);
            return(true);
        }
        else
        {
            mController.RemoveAndPool();

            /* machine.transform.SetParent(null);
             * machine.name = "Machine";
             * pool.PoolObject(machine); */
            return(false);
        }
    }