Example #1
0
    public static FlyAction GetSSAction(GameObject role_, Vector3 emitPosition_, Vector3 emitDirection_)
    {
        Fly(role_, emitPosition_, emitDirection_);
        FlyAction action = ScriptableObject.CreateInstance <FlyAction>();

        return(action);
    }
Example #2
0
    public static FlyAction GetSSAction(Vector3 direction, float angle, float power, bool go_)
    {
        FlyAction action = CreateInstance <FlyAction>();

        action.go           = go_;
        action.start_vector = Quaternion.Euler(new Vector3(0, 0, angle)) * Vector3.right * power;
        return(action);
    }
Example #3
0
    public static FlyAction GetSSAction(Vector3 _firstDirect)
    {
        FlyAction currentAction = ScriptableObject.CreateInstance <FlyAction>();

        currentAction.firstDirect = _firstDirect;
        currentAction.time        = 0;
        return(currentAction);
    }
Example #4
0
    public static FlyAction getAction(Vector3 direction, float speed)
    {
        FlyAction action = CreateInstance <FlyAction>();

        action.direction = direction;
        action.speed     = speed;
        return(action);
    }
Example #5
0
    public static FlyAction GetSSAction(Vector3 target, float speed)
    {
        FlyAction action = ScriptableObject.CreateInstance <FlyAction>();

        action.to = target;
        action.v  = speed;
        return(action);
    }
Example #6
0
    //根据飞行角度和速度获取一个FlyAction
    public static FlyAction GetSSAction(Vector3 angle, float speed)
    {
        FlyAction action = CreateInstance <FlyAction>();

        action.angle = angle;
        action.speed = speed;
        return(action);
    }
Example #7
0
 protected new void Start()
 {
     sceneController = Director.getInstance().currentSceneController as FirstSceneController;
     sceneController.ufoActionManager = this;
     slowFlyAction   = FlyAction.getAction(new Vector3(Random.Range(-1, 1f), Random.Range(-1, 1f)), slowSpeed);
     middleFlyAction = FlyAction.getAction(new Vector3(Random.Range(-1, 1f), Random.Range(-1, 1f)), middleSpeed);
     fastFlyAction   = FlyAction.getAction(new Vector3(Random.Range(-1, 1f), Random.Range(-1, 1f)), fastSpeed);
 }
Example #8
0
    public void UFOFly(DiskModel disk)
    {
        ruler.setRound(round);
        disk.disk.transform.position = ruler.getStart();//设置飞碟的出现位置
        int index = 0;

        for (; diskID[index] != -1; index++)
        {
            ;                                 //找到空闲的 Action
        }
        actions[index] = FlyAction.GetSSAction(ruler.getAngle(), ruler.getSpeed());
        diskID[index]  = disk.getDiskID();
        this.RunAction(disk.disk, actions[index], this);
    }
Example #9
0
    private Vector3 accelerateDirection = Vector3.zero; // 加速度的方向


    public static FlyAction GetAction(Vector3 direction, float angle, float power)
    {
        // 初始化飞碟的初速度方向
        FlyAction action = CreateInstance <FlyAction>();

        if (direction.x == -1)
        {
            action.startDirection = Quaternion.Euler(new Vector3(0, 0, -angle)) * Vector3.left * power;
        }
        else
        {
            action.startDirection = Quaternion.Euler(new Vector3(0, 0, angle)) * Vector3.right * power;
        }
        return(action);
    }
Example #10
0
 public void ActionEvent(Action source, GameObject gameObjectParam = null, ActionEventType events = ActionEventType.Compeleted,
                         int intParam = 0, string strParam = null)
 {
     if (events == ActionEventType.Started)
     {
         slowFlyAction   = FlyAction.getAction(new Vector3(Random.Range(-1, 1f), Random.Range(-1, 1f)), slowSpeed);
         middleFlyAction = FlyAction.getAction(new Vector3(Random.Range(-1, 1f), Random.Range(-1, 1f)), middleSpeed);
         fastFlyAction   = FlyAction.getAction(new Vector3(Random.Range(-1, 1f), Random.Range(-1, 1f)), fastSpeed);
         this.RunAction(gameObjectParam, source, this);
     }
     else if (events == ActionEventType.Compeleted)
     {
         UFOFactory ufofactory = Singleton <UFOFactory> .Instance;
         ufofactory.freeUFO(gameObjectParam);
     }
 }
Example #11
0
    public void UFOFly(DiskModel disk)
    {
        ruler.setRound(round);
        disk.disk.transform.position = ruler.getStart();//设置飞碟的出现位置
        int index = 0;

        for (; diskID[index] != -1; index++)
        {
            ;                                 //找到空闲的 Action
        }
        actions[index] = FlyAction.GetSSAction(ruler.getAngle(), ruler.getSpeed());
        diskID[index]  = disk.getDiskID();
        disk.disk.GetComponent <Rigidbody>().useGravity = false;
        disk.disk.GetComponent <Rigidbody>().velocity   = Vector3.zero;
        this.RunAction(disk.disk, actions[index], this);
    }
Example #12
0
    void updateFlightParameters(GameObject instance)
    {
        FlyAction flyAction = instance.GetComponent <FlyAction>();

        if (Random.value > 0.5f)
        {
            flyAction.changeDirection();
        }

        Vector3 curScale = instance.transform.localScale;

        float size = Random.Range(0.5f, 1.0f);

        instance.transform.localScale = curScale * size;

        flyAction.frequency = Random.Range(1f, 3f);
        flyAction.moveSpeed = Random.Range(1f, 4f);
        flyAction.magnitude = Random.Range(1f, 2.5f);

        flyAction.setBorder(spawnArea);
    }
Example #13
0
    public void runActionByRound(int round)
    {
        sumNum = round;
        isLose = false;
        GameObject disk;

        for (int i = 0; i < round; i += 2)
        {
            disk = dic.setDiskOnPos(leftEmitPos);

            FlyAction fly = FlyAction.GetSSAction(new Vector3(Random.Range(5f, 15), Random.Range(2.5f, 5), Random.Range(0, 0.75f)));
            this.runAction(disk, fly, this);
        }

        for (int i = 1; i < round; i += 2)
        {
            disk = dic.setDiskOnPos(rightRmitPos);

            FlyAction fly = FlyAction.GetSSAction(new Vector3(Random.Range(-15f, -5f), Random.Range(2.5f, 5), Random.Range(0, 0.75f)));
            this.runAction(disk, fly, this);
        }
        // 设置飞碟发射,发射round个飞碟
    }
        public int CalculateEstimate(State state)
        {
            int freePlaneStorageCount = 1; // + state.Planes.Min(p => p.FreeStorageCount);
            int freeVanStorageCount   = 1; // + state.Vans.Min(v => v.FreeStorageCount);

            int other          = 0;
            int totalFlyCost   = 0;
            int totalDriveCost = 0;

            foreach (var package in state.Packages.Where(p => !p.IsInDestination))
            {
                //have to fly
                if (package.Location.City != package.Destination.City)
                {
                    //have to get to the airport
                    if (!package.Location.IsAirport)
                    {
                        //no empty van there
                        if (!package.Location.Vans.Any(v => !v.IsFull))
                        {
                            other += new DriveAction().ActionCost;
                        }

                        if (package.LocationType != PackageLocationEnum.Van)
                        {
                            other += new LoadAction().ActionCost;
                        }

                        totalDriveCost += new DriveAction().ActionCost;
                        other          += new UnLoadAction().ActionCost;
                    }

                    //no plane there
                    if (!package.Location.City.Planes.Any(p => !p.IsFull))
                    {
                        other += new FlyAction().ActionCost;
                    }

                    //fly
                    if (package.LocationType != PackageLocationEnum.Plane)
                    {
                        other += new PickUpAction().ActionCost;
                    }

                    totalFlyCost += new FlyAction().ActionCost;

                    other += new DropOffAction().ActionCost;

                    //have to get from the airport
                    if (!package.Destination.IsAirport)
                    {
                        //no empty van there
                        if (!package.Destination.Vans.Any(v => !v.IsFull))
                        {
                            other += new DriveAction().ActionCost;
                        }

                        other          += new LoadAction().ActionCost;
                        totalDriveCost += new DriveAction().ActionCost;
                        other          += new UnLoadAction().ActionCost;
                    }
                }
                else //move just in city
                {
                    //no empty van there
                    if (!package.Location.Vans.Any(v => !v.IsFull))
                    {
                        other += new DriveAction().ActionCost;
                    }

                    if (package.LocationType == PackageLocationEnum.Plane)
                    {
                        other += new UnLoadAction().ActionCost;
                    }

                    if (package.LocationType != PackageLocationEnum.Van)
                    {
                        other += new LoadAction().ActionCost;
                    }

                    totalDriveCost += new DriveAction().ActionCost;

                    other += new UnLoadAction().ActionCost;
                }
            }
            return(other + totalFlyCost / freePlaneStorageCount + totalDriveCost / freeVanStorageCount);
        }
 public void flyUFO(GameObject disk, Vector3 target, float speed)
 {
     UFOAction = FlyAction.GetSSAction(target, speed);
     this.RunAction(disk, UFOAction, this);
 }
 //飞碟飞行
 public void UFOFly(GameObject disk, float angle, float power)
 {
     fly = FlyAction.GetSSAction(disk.GetComponent <DiskData>().direction, angle, power);
     this.RunAction(disk, fly, this);
 }
Example #17
0
 // Update is called once per frame
 public void Fly(GameObject role_, Vector3 emitPosition_, Vector3 emitDirection_)
 {
     fly = FlyAction.GetSSAction(role_, emitPosition_, emitDirection_);
     this.RunAction(role_, fly, this);
 }