示例#1
0
    public EnemyShipController PrefabInstantiate(PlanetController planet, Vector2 orbit, Vector2 position, bool immobile)
    {
        EnemyShipController    ship  = ((GameObject)Object.Instantiate(gameObject)).GetComponent <EnemyShipController>();
        FlyController          fly   = ship.GetComponent <FlyController>();
        PointGravityController pgrav = ship.GetComponent <PointGravityController>();
        HullController         hull  = ship.GetComponent <HullController>();
        Animator anim = ship.GetComponent <Animator>();

        ship.PrefabName = name;
        if (immobile)
        {
            ship.state = Modes.Appearing;

            ship.GetComponent <Rigidbody2D>().isKinematic = hull.InitialShieldPower > 0;

            ship.transform.position             = orbit;
            fly.enabled                         = false;
            pgrav.enabled                       = false;
            GetComponent <Collider2D>().enabled = false;
            anim.SetTrigger("Appear");
        }
        else
        {
            ship.state = Modes.Flying;
            fly.PrepareFly(orbit, planet);

            ship.transform.position = position;
        }


        ship.Planet = planet;


        return(ship);
    }
示例#2
0
    public AsteroidController PrefabInstantiate(PlanetController planet, Vector2 orbit, Vector2 position)
    {
        AsteroidController a   = ((GameObject)GameObject.Instantiate(gameObject)).GetComponent <AsteroidController>();
        FlyController      fly = a.GetComponent <FlyController>();

        a.transform.position = position;
        a.planet             = planet;
        fly.PrepareFly(orbit, planet);
        return(a);
    }