예제 #1
0
    IEnumerator UrgentPathCorrect()
    {
        while (!pathsCalculated)
        {
            yield return(new WaitForSeconds(0.05f));
        }
        yield return(new WaitForSeconds(0.1f));

        float    mini  = 100f;
        PathDest fDest = null;

        foreach (PathDest dest in goalList)
        {
            if (mapSCR.IsRoomEmpty(dest.endPoint, isAlly) != null)
            {
                if (dest.pathDist < mini)
                {
                    if (Vector3.Distance(dest.endPoint, mapSCR.GetRoomByPos(transform.position).roomPosition) > 0.1f)
                    {
                        mini  = dest.pathDist;
                        fDest = dest;
                    }
                }
            }
        }
        if (fDest != null)
        {
            MoveToNode(fDest.endPoint);
        }
        else
        {
            MagicTp();
        }
    }
예제 #2
0
    // Use this for initialization
    void Start()
    {
        playerMvntSCR = GetComponent <PlayerMovement>();
        globalMap     = GameObject.FindGameObjectWithTag("Manager").GetComponent <ShipMap>();
        if (isAlly)
        {
            engineMng = GameObject.FindGameObjectWithTag("MainShip").GetComponent <EnginesManager>();
        }
        else
        {
            engineMng = GameObject.FindGameObjectWithTag("Enemy").GetComponent <EnginesManager>();
        }
        medicEngine = engineMng.GetEngine(Engine.engineType.medic);
        if (medicEngine == null)
        {
            StartCoroutine(initCrt());
            return;
        }
        Vector3 medicPos = globalMap.GetEnginePos(Engine.engineType.medic, isAlly);

        foreach (ShipCell cell in globalMap.GetRoomByPos(medicPos).cells)
        {
            medicsPos.Add(cell.position);
        }
        StartCoroutine(RepairCoroutine());
        StartCoroutine(OperateCrt());
    }
예제 #3
0
    IEnumerator RepairCoroutine()
    {
        while (true)
        {
            bool repairing = false;
            if (isMoving)
            {
                yield return(new WaitForSeconds(0.1f));

                continue;
            }
            if (isAlly)  // si allié et sur le ship allié
            {
                ShipRoom myRoom = globalMap.GetRoomByPos(transform.position);
                if (myRoom != null)
                {
                    if (myRoom.engine.currentHp < myRoom.engine.maxHp)
                    {
                        repairing = true;
                        myRoom.engine.Repair(repairPower + repairOpeLevel);
                        GainExp(Engine.engineType.repairModule);
                    }
                }
            }
            else // si pas allié et pas sur le ship allié
            {
                ShipRoom myRoom = globalMap.GetRoomByPos(transform.position);
                if (myRoom != null)
                {
                    if (myRoom.engine.currentHp < myRoom.engine.maxHp)
                    {
                        repairing = true;
                        myRoom.engine.Repair(repairPower + repairOpeLevel);
                    }
                }
            }
            if (repairing)
            {
                isRepairing = true;
            }
            else
            {
                isRepairing = false;
            }
            yield return(new WaitForSeconds(0.1f));
        }
    }
예제 #4
0
    // Use this for initialization
    void Start()
    {
        playerMvntSCR = GetComponent<PlayerMovement>();
        globalMap = GameObject.FindGameObjectWithTag("Manager").GetComponent<ShipMap>();
        if (isAlly)
        {
            engineMng = GameObject.FindGameObjectWithTag("MainShip").GetComponent<EnginesManager>();
        }
        else
        {
            engineMng = GameObject.FindGameObjectWithTag("Enemy").GetComponent<EnginesManager>();
        }
        medicEngine = engineMng.GetEngine(Engine.engineType.medic);
        if (medicEngine == null)
        {
            StartCoroutine(initCrt());
            return;

        }
        Vector3 medicPos = globalMap.GetEnginePos(Engine.engineType.medic, isAlly);
        foreach (ShipCell cell in globalMap.GetRoomByPos(medicPos).cells)
        {
            medicsPos.Add(cell.position);
        }
        StartCoroutine(RepairCoroutine());
        StartCoroutine(OperateCrt());
    }