//public SoldierDamageAnimPack GetAnimDamagePackByName(string name)
    //{
    //    foreach (SoldierDamageAnimPack adp in animDamages)
    //    {
    //        if (adp.name == name)
    //            return adp;
    //    }

    //    return null;
    //}

    public SoldierMovementInfo GetMovementInfoByType(MovementTypeEnum _movementType)
    {
        foreach (SoldierMovementInfo mi in movementInfos)
        {
            if (mi.movementType == _movementType)
            {
                return(mi);
            }
        }

        return(null);
    }
Exemple #2
0
 protected void MvmtManual()
 {
     if (Vector2.Distance(transform.position, goalLocation) < 0.2f)
     {
         FillMoveSpots();
         aiMvmt = MovementTypeEnum.Patrol;
         Debug.Log("Reached manually set location");
     }
     else
     {
         transform.position = Vector2.MoveTowards(transform.position, goalLocation, fMoveSpeed * Time.deltaTime);
         Vector2 dir   = goalLocation - transform.position;
         var     angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg;
         transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);
         feetAnimation.SetBool("Moving", true);
     }
 }
Exemple #3
0
    int playersToAvoid;// = LayerMask.GetMask("Player"); // Used by Safe aiMvmt.

    void Start()
    {
        layerMask = (1 << 4) | (1 << 9) | (1 << 12);
        //layersToAvoid.layerMask = 4608;//
        layersToAvoid.layerMask = LayerMask.GetMask("Obstacles", "Player"); // It may be helpful to put Enemies in seperate layer or get rid of Player layer.
        playersToAvoid          = LayerMask.GetMask("Player");
        fWaitTime = fStartWaitTime;

        frameToCastOn = Random.Range(0, MAX_FRAMES_BETWEEN_RAYCASTS);

        iRandomSpot = 0;
        if (aiMvmt == MovementTypeEnum.None)
        {
            FillMoveSpots();
            aiMvmt = MovementTypeEnum.Patrol;
        }
        rb = GetComponent <Rigidbody2D>();
        HealthBarHandler = GetComponent <HealthBarHandler>();
        HealthBarHandler.SetMaxHP(fHP);
        feetAnimation = transform.GetChild(2).GetComponent <Animator>();
    }
Exemple #4
0
    protected void Damaged(object[] storage)
    {
        try
        {
            Debug.Log("Rececived " + (int)storage[0] + " damage");
            fHP -= (int)storage[0];
            HealthBarHandler.OnDamaged(fHP);

            Debug.Log("Enemy HP =" + fHP);
            Debug.Log("storage = " + storage);
            Debug.Log("storage[0] = " + storage[0]);
            Debug.Log("storage[1] = " + storage[1]);

            if (storage[1] != null)
            {
                GameObject temp = (GameObject)storage[1];
                Debug.Log("player =" + temp);
                if (temp.GetComponent <Player>() != null && fHP <= 0)
                {
                    Debug.Log("Enemy died, exp should have went to " + temp);
                    EventAggregator.GetInstance().Publish <OnEnemyKilledEvent>(new OnEnemyKilledEvent(temp.GetComponent <Player>().playerNumber, 100));
                }
                if (playerTarget == null && Vector3.Distance(temp.transform.position, gameObject.transform.position) < fVisionDistance)
                {
                    Debug.Log("Detected that " + temp.name + " shot at enemy");
                    playerTarget = temp;
                    aiMvmt       = MovementTypeEnum.Chase;
                }
                else
                {
                    Debug.Log("Was shot at but distance [" + Vector3.Distance(temp.transform.position, gameObject.transform.position) + "] was too far");
                }
            }
        }
        catch (System.InvalidCastException e)
        {
            Debug.Log("Cast exception in enemy's damaged function");
        }
    }
Exemple #5
0
        public static uint GetVelocity(PathElement cell, MovementTypeEnum moveType)
        {
            if (cell.Orientation % 2 == 0)
            {
                if (cell.Orientation % 4 == 0)
                {
                    switch (moveType)
                    {
                    case MovementTypeEnum.MOUNTED:
                        return(200);

                    case MovementTypeEnum.PARABLE:
                        return(500);

                    case MovementTypeEnum.RUNNING:
                        return(255);

                    case MovementTypeEnum.SLIDE:
                        return(255 * 3);

                    case MovementTypeEnum.WALKING:
                        return(510);
                    }
                }

                // VERTICAL DIAGONAL VELOCITY

                switch (moveType)
                {
                case MovementTypeEnum.MOUNTED:
                    return(120);

                case MovementTypeEnum.PARABLE:
                    return(450);

                case MovementTypeEnum.RUNNING:
                    return(150);

                case MovementTypeEnum.SLIDE:
                    return(150 * 3);

                case MovementTypeEnum.WALKING:
                    return(425);
                }
            }

            // LINEAR VELOCITY

            switch (moveType)
            {
            case MovementTypeEnum.MOUNTED:
                return(135);

            case MovementTypeEnum.PARABLE:
                return(400);

            case MovementTypeEnum.RUNNING:
                return(170);

            case MovementTypeEnum.SLIDE:
                return(170 * 3);

            case MovementTypeEnum.WALKING:
                return(480);
            }

            return(0);
        }
 /// <summary>
 /// GET api/CashVouchers/Default
 /// Returns default cash voucher. This resource is suitable for creation of new contact by the POST method.
 /// </summary>
 public CashVoucher Default(MovementTypeEnum movementType)
 {
     return(Get <CashVoucher>(ResourceUrl + "/Default" + "/" + (int)movementType));
 }
Exemple #7
0
 public static int GetPathVelocity(List <CellWithOrientation> cells, MovementTypeEnum moveType)
 {
     return(cells
            .Aggregate(0, (current, cell) => current + GetVelocity(cell, moveType)));
 }
Exemple #8
0
 public static uint GetPathVelocity(MovementPath cells, MovementTypeEnum moveType)
 {
     return(cells.Cells.Aggregate <PathElement, uint>(0,
                                                      (current, cell) => current + GetVelocity(cell, moveType)));
 }
 public static int GetPathVelocity(MovementPath path, MovementTypeEnum moveType)
 {
     return(path.Cells.Sum(cell => GetVelocity(cell, moveType)));
 }
Exemple #10
0
        public static int GetVelocity(CellWithOrientation cell, MovementTypeEnum moveType)
        {
            if (cell.Orientation % 2 == 0)
            {
                if (cell.Orientation % 4 == 0)
                {
                    switch (moveType)
                    {
                    case MovementTypeEnum.Mounted:
                        return(200);

                    case MovementTypeEnum.Parable:
                        return(500);

                    case MovementTypeEnum.Running:
                        return(255);

                    case MovementTypeEnum.Slide:
                        return(255 * 3);

                    case MovementTypeEnum.Walking:
                        return(510);
                    }
                }

                switch (moveType)
                {
                case MovementTypeEnum.Mounted:
                    return(120);

                case MovementTypeEnum.Parable:
                    return(450);

                case MovementTypeEnum.Running:
                    return(150);

                case MovementTypeEnum.Slide:
                    return(150 * 3);

                case MovementTypeEnum.Walking:
                    return(425);
                }
            }

            switch (moveType)
            {
            case MovementTypeEnum.Mounted:
                return(135);

            case MovementTypeEnum.Parable:
                return(400);

            case MovementTypeEnum.Running:
                return(170);

            case MovementTypeEnum.Slide:
                return(170 * 3);

            case MovementTypeEnum.Walking:
                return(480);
            }
            return(0);
        }
    public override void UpdateAct()
    {
        base.UpdateAct();

        #region Pre
        if (doPres)
        {
            if (ShouldCheckPlayerCriticalSitu())
            {
                soldInfo.SlowlyUpdatePlayerCritic();
            }

            #region FightInPoint
            if (pre_FightInPoint)
            {
                DoPre_FightInPoint();
            }
            #endregion
        }
        #endregion

StartSteps:

        #region Start01
        if (step == FightInRegStep.Start01)
        {
            if (ShouldStartCampMode())
            {
                step = FightInRegStep.Camp01;
            }
            else
            {
                step = FightInRegStep.TryStartMoving01;
            }
        }
        #endregion

        #region TryStartMoving01
        if (step == FightInRegStep.TryStartMoving01)
        {
            if (needsToBeFinished)
            {
                SetFinished(true);
                return;
            }

            if (!NeedsDistantMoveToGetToPos(controlledSoldier.transform.position, selectedFightPoint.transform.position))
            {
                step = FightInRegStep.ShortMoving01;
                goto StartSteps;
            }

            step = FightInRegStep.NoramlMoving01;
            goto StartSteps;

            //if (IsSoldOnPoint(controlledSoldier.gameObject, selectedFightPoint.transform.position, maxErrorToPos))
            //{
            //    step = FightInRegStep.FightingInPoint01;
            //    goto StartSteps;
            //}
            //else
            //{
            //    Vector3[] newPath;

            //    if (mapLogic.FindCurvePath(controlledSoldier.transform.position, selectedFightPoint.transform.position, maxErrorToPos, out newPath))
            //    {
            //        currentMovementPath = newPath;
            //        step = FightInRegStep.NoramlMoving01;
            //        goto StartSteps;
            //    }
            //    else
            //    {
            //        step = FightInRegStep.TryStartMoving02;
            //        goto StartSteps;
            //    }
            //}
        }
        #endregion

        #region TryStartMoving02
        if (step == FightInRegStep.TryStartMoving02)
        {
            aStarResultTimeCounter = aStarResultMaxTime;
            soldInfo.FindNewAStarPath(controlledSoldier.transform.position, selectedFightPoint.transform.position);
            step = FightInRegStep.TryStartMoving03;
            goto StartSteps;
        }
        #endregion

        #region TryStartMoving03
        if (step == FightInRegStep.TryStartMoving03)
        {
            if (needsToBeFinished)
            {
                SetFinished(true);
                return;
            }

            if (soldInfo.isAStarPathResultRecievedInThisRun)
            {
                if (!soldInfo.isAStarPathError)
                {
                    currentMovementPath = soldInfo.aStarLastPath;
                    step = FightInRegStep.NoramlMoving01;
                    goto StartSteps;
                }
                else
                {
                    //FightPoint fp;
                    //if (IsSoldierOnAPoint(out fp))
                    //{
                    //    //<Temp>
                    //    Debug.LogError("No path founded to point!");
                    //    //</Temp>

                    //    selectedFightPoint = fp;
                    //    step = FightInRegStep.FightingInPoint01;
                    //    goto StartSteps;
                    //}

                    //<Temp>
                    Debug.LogError("No path founded to point!");
                    //</Temp>

                    time_SelectNewPointToGoFromFightingInPos_Counter = time_SelectNewPointToGoFromFightingInPos_Max_WhileNoPath;
                    step = FightInRegStep.FightingInPos01;
                    goto StartSteps;
                }
            }

            aStarResultTimeCounter -= Time.deltaTime;
            if (aStarResultTimeCounter <= 0)
            {
                //<Temp>
                Debug.LogError("No path founded in needed time!");
                //</Temp>

                //FightPoint fp;
                //if (IsSoldierOnAPoint(out fp))
                //{
                //    selectedFightPoint = fp;
                //    step = FightInRegStep.FightingInPoint01;
                //    goto StartSteps;
                //}

                time_SelectNewPointToGoFromFightingInPos_Counter = time_SelectNewPointToGoFromFightingInPos_Max_WhileNoPath;
                step = FightInRegStep.FightingInPos01;
                goto StartSteps;
            }
        }
        #endregion

        #region NoramlMoving01
        if (step == FightInRegStep.NoramlMoving01)
        {
            if (needsToBeFinished)
            {
                SetFinished(true);
                return;
            }

            initialTargetForAfterMovementChecked = false;
            shouldSetInitialTargForFightInPoint  = false;
            initialTargetForFightInPoint         = null;

            currentMovementType = fightReg.movementType; //GetMovementTypeForMovingToTarget(currentMovementPath);

            movementAct = controlledSoldier.gameObject.AddComponent <SoldierAction_Movement>();
            movementAct.Init(controlledSoldier);
            movementAct.InitDefaultParams(currentMovementType);
            movementAct.initialEnemies = initialEnemies;

            if (doMoveFight)
            {
                movementAct.Init_DoFightWhileMove(true);
            }


            //SetMovementParams(currentMovementType);

            movementAct.SetNextActAnimToCrossfade(selectedFightPoint.defaultfightInfo.GetAStartAnim());
            movementAct.SetEndingRotNormal(selectedFightPoint.transform.forward);

            movementAct.Init_PosToFindPath(selectedFightPoint.transform.position);

            //movementAct.Init_SetPath(currentMovementPath);

            movementAct.StartAct();
            SetCurrentAction(movementAct);

            step = FightInRegStep.NoramlMoving02;
        }
        #endregion

        #region NoramlMoving02
        if (step == FightInRegStep.NoramlMoving02)
        {
            if (needsToBeFinished)
            {
                movementAct.SetNeedsToBeFinished(evenStopMovingForFinish);
                step = FightInRegStep.Finishing01;
                goto StartSteps;
            }

            if (!initialTargetForAfterMovementChecked && movementAct.isBeforeEndAnimRun)
            {
                initialTargetForAfterMovementChecked = true;

                GameObject targ = SelectBestTargetForPoint(selectedFightPoint);

                if (targ != null)
                {
                    shouldSetInitialTargForFightInPoint = true;
                    initialTargetForFightInPoint        = targ;
                    movementAct.SetEndingRotLookTarget(initialTargetForFightInPoint.transform);

                    gunDirForFightInPointInitialTarget = SoldierStats.GetSoldierGunDirectionForTarget(controlledSoldier.gameObject, initialTargetForFightInPoint);

                    movementAct.SetNextActAnimToCrossfade(selectedFightPoint.defaultfightInfo.GetAnimList_FightLookAllBody(gunDirForFightInPointInitialTarget).GetRandomAnimName());
                }
            }

            if (movementAct.finishReport == FinishReportEnum.FinishedOK)
            {
                if (selectedFightPoint == initialPoint)
                {
                    needsToGoToInitialPoint = false;
                }

                Destroy(movementAct);
                SetCurrentAction(null);
                step = FightInRegStep.FightingInPoint01;
                goto StartSteps;
            }


            if (!movementAct.isEndingV && SlowlyCheckPlayerCritStateWhileMoving())
            {
                step = FightInRegStep.NoramlMoving_StopMovingAndGoToFightInPos01;
                goto StartSteps;
            }
        }
        #endregion

        #region NoramlMoving_StopMovingAndGoToFightInPos01
        if (step == FightInRegStep.NoramlMoving_StopMovingAndGoToFightInPos01)
        {
            if (IsPlayerStillInCriticSitu())
            {
                shouldSetPlayerAsTargetForFightInPos  = true;
                gunDirForTargettingPlayerInFightInPos = SoldierStats.GetSoldierGunDirectionForTarget(controlledSoldier.gameObject, mapLogic.player);

                Transform playerTr = null;

                if (mapLogic.player != null)
                {
                    playerTr = mapLogic.player.transform;
                }

                movementAct.SetNeedsToStop(normalMovementStopTime, onPosFightInPointInfo.GetAnimList_FightLookAllBody(gunDirForTargettingPlayerInFightInPos).GetRandomAnimName(), playerTr);
            }
            else
            {
                movementAct.SetNeedsToStop(normalMovementStopTime, onPosFightInPointInfo.GetAStartAnim());
            }

            step = FightInRegStep.NoramlMoving_StopMovingAndGoToFightInPos02;
        }
        #endregion

        #region NoramlMoving_StopMovingAndGoToFightInPos02
        if (step == FightInRegStep.NoramlMoving_StopMovingAndGoToFightInPos02)
        {
            if (movementAct.finishReport == FinishReportEnum.FinishedOK)
            {
                Destroy(movementAct);
                SetCurrentAction(null);
                step = FightInRegStep.FightingInPos00;
            }
        }
        #endregion

        #region FightingInPos00
        if (step == FightInRegStep.FightingInPos00)
        {
            time_SelectNewPointToGoFromFightingInPos_Counter = time_SelectNewPointToGoFromFightingInPos_Max;
            step = FightInRegStep.FightingInPos01;
        }
        #endregion

        #region FightingInPos01
        if (step == FightInRegStep.FightingInPos01)
        {
            if (needsToBeFinished)
            {
                SetFinished(true);
                return;
            }

            fightInPointAct = controlledSoldier.gameObject.AddComponent <SoldierAction_FightInPoint>();
            fightInPointAct.Init(controlledSoldier);
            fightInPointAct.InitForPos(controlledSoldier.transform.position, controlledSoldier.transform.rotation, onPosFightInPointInfo);
            fightInPointAct.InitAIVoiceSitu(voiceSituation);
            fightInPointAct.initialEnemies = initialEnemies;

            if (shouldSetPlayerAsTargetForFightInPos)
            {
                fightInPointAct.Init_StartInShootSituForTarget(mapLogic.player);
                fightInPointAct.currentGunDirection = gunDirForTargettingPlayerInFightInPos;

                shouldSetPlayerAsTargetForFightInPos = false;
            }

            fightInPointAct.SetOwnerFightInRegAct(this);

            fightInPointAct.StartAct();

            SetCurrentAction(fightInPointAct);

            step = FightInRegStep.FightingInPos02;
        }
        #endregion

        #region FightingInPos02
        if (step == FightInRegStep.FightingInPos02)
        {
            if (needsToBeFinished)
            {
                fightInPointAct.SetNeedsToBeFinished(evenStopMovingForFinish);
                step = FightInRegStep.Finishing01;
                goto StartSteps;
            }

            time_SelectNewPointToGoFromFightingInPos_Counter = MathfPlus.DecByDeltatimeToZero(time_SelectNewPointToGoFromFightingInPos_Counter);

            if (IsPlayerStillInCriticSitu())
            {
                time_CheckPlayerInCritStateWhileInFightInPos_Counter = MathfPlus.DecByDeltatimeToZero(time_CheckPlayerInCritStateWhileInFightInPos_Counter);

                if (time_CheckPlayerInCritStateWhileInFightInPos_Counter <= 0)
                {
                    time_CheckPlayerInCritStateWhileInFightInPos_Counter = time_CheckPlayerInCritStateWhileInFightInPos_Max;

                    if (!soldInfo.IsPlayerInView())
                    {
                        if (time_SelectNewPointToGoFromFightingInPos_Counter == 0)
                        {
                            time_SelectNewPointToGoFromFightingInPos_Counter = time_SelectNewPointToGoFromFightingInPos_Max;

                            //<Temp>
                            newFightPointToGo = SelectBestFightPointForPlayerCritState();
                            step = FightInRegStep.FightingInPoint_ChangePoint01;
                            //</Temp>

                            goto StartSteps;
                        }
                    }
                }
            }
            else
            {
                if (time_SelectNewPointToGoFromFightingInPos_Counter == 0)
                {
                    time_SelectNewPointToGoFromFightingInPos_Counter = time_SelectNewPointToGoFromFightingInPos_Max;

                    newFightPointToGo = SelectNewFightPoint();
                    step = FightInRegStep.FightingInPoint_ChangePoint01;
                    goto StartSteps;
                }
            }
        }
        #endregion

        #region FightingInPoint01
        if (step == FightInRegStep.FightingInPoint01)
        {
            if (needsToBeFinished)
            {
                SetFinished(true);
                return;
            }

            pre_FightInPoint = true;

            //ResetDelayTimeToChangePoint();
            //ResetTimeToGoToClosePoint();
            ResetTimeToCheckAvailableTargets();
            ResetTime_ChangePoint();

            fightInPointAct = controlledSoldier.gameObject.AddComponent <SoldierAction_FightInPoint>();
            fightInPointAct.Init(controlledSoldier);
            fightInPointAct.InitForFightPoint(selectedFightPoint);
            fightInPointAct.InitAIVoiceSitu(voiceSituation);
            fightInPointAct.initialEnemies = initialEnemies;

            if (shouldSetInitialTargForFightInPoint)
            {
                fightInPointAct.Init_StartInShootSituForTarget(initialTargetForFightInPoint);
                fightInPointAct.currentGunDirection = gunDirForFightInPointInitialTarget;
            }

            fightInPointAct.SetOwnerFightInRegAct(this);

            fightInPointAct.StartAct();

            if (nowReadyForGreandeLaunch)
            {
                fightInPointAct.SetItsNowReadyForLaunchGrenade();
            }

            SetCurrentAction(fightInPointAct);

            step = FightInRegStep.FightingInPoint02;
        }
        #endregion

        #region FightingInPoint02
        if (step == FightInRegStep.FightingInPoint02)
        {
            if (needsToBeFinished)
            {
                fightInPointAct.SetNeedsToBeFinished(evenStopMovingForFinish);
                step = FightInRegStep.Finishing01;
                goto StartSteps;
            }

            if (IsPlayerStillInCriticSitu())
            {
                time_CheckPlayerInCritStateWhileInFightInPoint_Counter = MathfPlus.DecByDeltatimeToZero(time_CheckPlayerInCritStateWhileInFightInPoint_Counter);

                if (time_CheckPlayerInCritStateWhileInFightInPoint_Counter <= 0)
                {
                    time_CheckPlayerInCritStateWhileInFightInPoint_Counter = time_CheckPlayerInCritStateWhileInFightInPoint_Max;

                    if (!CheckIsCurrentPointOkForPlayerCritState())
                    {
                        FightPoint newFP = SelectBestFightPointForPlayerCritState();

                        if (newFP != selectedFightPoint)
                        {
                            newFightPointToGo = newFP;

                            step = FightInRegStep.FightingInPoint_ChangePoint01;
                            goto StartSteps;
                        }
                    }
                }
            }
            else
            {
                bool newPointSelected = false;

                if (timeToCheckAvailableTargets_Counter == 0)
                {
                    ResetTimeToCheckAvailableTargets();

                    List <CharRayCastRsltForFightInPoInf> targsResults;

                    targsResults = mapLogic.GetAllAttackableEnemiesForListOfFightInfos(selectedFightPoint.fightInfos, controlledSoldier.gameObject, initialEnemies, selectedFightPoint.transform.position, selectedFightPoint.transform.rotation);

                    float sumOfRatings = 0;

                    sumOfRatings = mapLogic.GetSumOfRatings(targsResults);

                    if (sumOfRatings == 0)
                    {
                        FightPointWithRating newFPWithRating = SelectNewFightPointWithRating();

                        if (newFPWithRating != null &&
                            newFPWithRating.fightPoint != null &&
                            newFPWithRating.fightPoint != selectedFightPoint &&
                            newFPWithRating.rating > sumOfRatings)
                        {
                            newPointSelected  = true;
                            newFightPointToGo = newFPWithRating.fightPoint;

                            step = FightInRegStep.FightingInPoint_ChangePoint01;
                            goto StartSteps;
                        }
                    }
                }

                if (!newPointSelected)
                {
                    if (time_ChangePoint_Counter == 0)
                    {
                        ResetTime_ChangePoint();

                        List <FightPointWithRating> fightPointWithRatings = mapLogic.RateFightPointsAndSort(fightReg.GetFightPointsOfLane(soldInfo.curFightRegLaneNum), controlledSoldier.gameObject, initialEnemies);

                        if (fightPointWithRatings.Count == 1)
                        {
                            if (fightPointWithRatings[0].fightPoint != selectedFightPoint)
                            {
                                newPointSelected  = true;
                                newFightPointToGo = fightPointWithRatings[0].fightPoint;

                                step = FightInRegStep.FightingInPoint_ChangePoint01;
                                goto StartSteps;
                            }
                        }

                        if (fightPointWithRatings.Count > 1)
                        {
                            if (fightPointWithRatings[0].fightPoint != selectedFightPoint)
                            {
                                newPointSelected  = true;
                                newFightPointToGo = fightPointWithRatings[0].fightPoint;

                                step = FightInRegStep.FightingInPoint_ChangePoint01;
                                goto StartSteps;
                            }
                            else
                            {
                                fightPointWithRatings[0].rating *= (1 - Random.Range(0f, maxValueToDecreaseFromCurrentPointRating));

                                if (fightPointWithRatings[1].rating >= fightPointWithRatings[0].rating)
                                {
                                    if (fightPointWithRatings[1].rating > 0)
                                    {
                                        newPointSelected  = true;
                                        newFightPointToGo = fightPointWithRatings[1].fightPoint;

                                        step = FightInRegStep.FightingInPoint_ChangePoint01;
                                        goto StartSteps;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        #endregion

        #region FightingInPoint_ChangePoint01
        if (step == FightInRegStep.FightingInPoint_ChangePoint01)
        {
            if (fightInPointAct != null && fightInPointAct.status != ActionStatusEnum.Finished)
            {
                fightInPointAct.SetNeedsToBeFinished(evenStopMovingForFinish);
            }

            step = FightInRegStep.FightingInPoint_ChangePoint02;
        }
        #endregion

        #region FightingInPoint_ChangePoint02
        if (step == FightInRegStep.FightingInPoint_ChangePoint02)
        {
            if ((fightInPointAct != null && fightInPointAct.status == ActionStatusEnum.Finished) || fightInPointAct == null)
            {
                if (fightInPointAct != null)
                {
                    Destroy(fightInPointAct);
                }

                SetCurrentAction(null);
                pre_FightInPoint = false;

                selectedFightPoint = newFightPointToGo;
                step = FightInRegStep.TryStartMoving01;
            }
        }
        #endregion

        #region Finishing01
        if (step == FightInRegStep.Finishing01)
        {
            if (currentAction == null)
            {
                SetFinished(true);
                step = FightInRegStep.Finishing02;
                goto StartSteps;
            }

            //<Alpha>
            if (needsToBeFinished)
            {
                currentAction.SetNeedsToBeFinished(evenStopMovingForFinish);
            }
            //</Alpha>

            if (currentAction.status == ActionStatusEnum.Finished)
            {
                Destroy(currentAction);
                SetCurrentAction(null);

                SetFinished(true);
                step = FightInRegStep.Finishing02;
                goto StartSteps;
            }
        }
        #endregion

        #region Camp01
        if (step == FightInRegStep.Camp01)
        {
            if (needsToBeFinished)
            {
                SetFinished(true);
                return;
            }

            campAct = controlledSoldier.gameObject.AddComponent <SoldierAction_Camp>();
            campAct.Init(controlledSoldier);

            if (campCurveInfos != null)
            {
                campAct.InitCampCurveInfos(campCurveInfos);
            }
            else
            {
                campAct.InitCampType(campInfo.campType);
            }

            campAct.StartAct();

            SetCurrentAction(campAct);

            step = FightInRegStep.Camp02;
        }
        #endregion

        #region Camp02
        if (step == FightInRegStep.Camp02)
        {
            if (needsToBeFinished)
            {
                campAct.SetNeedsToBeFinished(evenStopMovingForFinish);
                step = FightInRegStep.Finishing01;
                goto StartSteps;
            }

            if (campAct.playerHasBeenDetected)
            {
                SetPlayerIsDetectedInCampMode();
            }

            if (isPlayerDetectedInCampMode)
            {
                step = FightInRegStep.CampFinishingForStartingNormalMode01;
                goto StartSteps;
            }
        }
        #endregion

        #region CampFinishingForStartingNormalMode01
        if (step == FightInRegStep.CampFinishingForStartingNormalMode01)
        {
            campAct.SetNeedsToBeFinished(true);

            step = FightInRegStep.CampFinishingForStartingNormalMode02;
            goto StartSteps;
        }
        #endregion

        #region CampFinishingForStartingNormalMode02
        if (step == FightInRegStep.CampFinishingForStartingNormalMode02)
        {
            if (campAct == null || (campAct != null && campAct.status == ActionStatusEnum.Finished))
            {
                if (campAct != null)
                {
                    Destroy(campAct);
                }

                SetCurrentAction(null);
                step = FightInRegStep.TryStartMoving01;
            }
        }
        #endregion
    }
Exemple #12
0
 public void Init_MovementType(MovementTypeEnum _movementType)
 {
     currentMovementType = _movementType;
 }
Exemple #13
0
 /// <summary>
 /// GET api/IssuedInvoices/Default/{movementType}/{invoiceType}/{invoiceId}
 /// Method returns empty cash voucher with default values. Returned resource is suitable for creation of a new cash voucher.
 /// </summary>
 public CashVoucherCreate Default(MovementTypeEnum movementType, InvoiceTypeEnum invoiceType, int invoiceId)
 {
     return(Get <CashVoucherCreate>(ResourceUrl + "/Default/" + (int)movementType + "/" + (int)invoiceType + "/" + invoiceId));
 }
Exemple #14
0
 public void SetManualDestination(Vector3 pDestination)
 {
     Debug.Log("Manual destination set");
     goalLocation = pDestination;
     aiMvmt       = MovementTypeEnum.Manual;
 }
Exemple #15
0
 /// <summary>
 /// GET api/CashVouchers/Default
 /// Returns default cash voucher. This resource is suitable for creation of new contact by the POST method.
 /// </summary>
 public async Task <CashVoucher> DefaultAsync(MovementTypeEnum movementType)
 {
     return(await GetAsync <CashVoucher>(ResourceUrl + "/Default" + "/" + (int)movementType));
 }
Exemple #16
0
    // Update is called once per frame
    void FixedUpdate()
    {
        //death
        if (fHP <= 0)
        {
            Object.Destroy(gameObject);
            Destroy(this);
        }

        canShoot    = true;
        frameCount += 1;
        frameCount %= MAX_FRAMES_BETWEEN_RAYCASTS;
        if (aiMvmt != MovementTypeEnum.Manual && frameCount == frameToCastOn)
        {
            EnemyRayCast();
        }

        if (fHP <= LOW_HP_THRESHOLD)
        {
            aiMvmt = MovementTypeEnum.Safe;
        }
        else if (playerTarget != null)
        {
            aiMvmt = MovementTypeEnum.Chase;
        }
        else if (aiMvmt != MovementTypeEnum.Manual)
        {
            aiMvmt = MovementTypeEnum.Patrol;
        }

        switch (aiMvmt)
        {
        case MovementTypeEnum.Patrol:
            MvmtPatrol();
            break;

        case MovementTypeEnum.Chase:
            MvmtChase();
            break;

        case MovementTypeEnum.Safe:
            MvmtSafe();
            break;

        case MovementTypeEnum.Manual:
            MvmtManual();
            break;
        }

        if (playerTarget != null && playerTarget.GetComponent <Player>().PlayerState != PlayerState.ALIVE)
        {
            playerTarget = null;
        }

        if ((canShoot && ((aiMvmt == MovementTypeEnum.Chase && playerTarget != null) ||
                          (aiMvmt == MovementTypeEnum.Safe && !withInMinDistance)) && Time.time > fAttackTime) &&
            raycasts[(int)RayCastDir.Forward].collider != null && raycasts[(int)RayCastDir.Forward].collider.gameObject == playerTarget &&
            Vector2.Distance(transform.position, playerTarget.transform.position) < attackDistance)
        {
            Debug.Log("RayCastDir.forward collider tag = " + raycasts[(int)RayCastDir.Forward].collider.tag + "    collider name = " + raycasts[(int)RayCastDir.Forward].collider.name);
            //face player
            Vector2 dir   = playerTarget.transform.position - shootPosition.position;
            var     angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg;
            transform.rotation = Quaternion.RotateTowards(transform.rotation, Quaternion.AngleAxis(angle, Vector3.forward), fRotationSpeed * Time.deltaTime);

            //shoot straight
            var x = Instantiate(bullet, this.shootPosition.position, this.shootPosition.rotation);
            x.SetDamage(fDamage);
            x.SetTarget("Player");

            x.setSound(FireSound);

            x.GetComponent <Rigidbody2D>().AddForce(x.transform.right * 800);

            fAttackTime = Time.time + iBaseAttackRate;
        }
    }
Exemple #17
0
 /// <summary>
 /// GET api/IssuedInvoices/Default/{movementType}/{invoiceType}/{invoiceId}
 /// Method returns empty cash voucher with default values. Returned resource is suitable for creation of a new cash voucher.
 /// </summary>
 public async Task <CashVoucherCreate> DefaultAsync(MovementTypeEnum movementType, InvoiceTypeEnum invoiceType, int invoiceId)
 {
     return(await GetAsync <CashVoucherCreate>(ResourceUrl + "/Default/" + (int)movementType + "/" + (int)invoiceType + "/" + invoiceId));
 }