コード例 #1
0
ファイル: Team.cs プロジェクト: oopartians/SpaceBattle
 void Awake()
 {
     aiInfor = gameObject.GetComponent<TeamAIInformation> ();
 }
コード例 #2
0
    public void Ready()
    {
        fleet      = GetComponent <Fleet> ();
        teamAIInfo = fleet.team.aiInfor;
        engine     = new ScriptEngine();
        InitJSValues();


        // Create an instance of the Jurassic engine then expose some stuff to it.
        engine.SetGlobalValue("console", new Jurassic.Library.FirebugConsole(engine));

        // Arguments and returns of functions exposed to JavaScript must be of supported types.
        // Supported types are bool, int, double, string, Jurassic.Null, Jurassic.Undefined
        // and Jurassic.Library.ObjectInstance (or a derived type).
        // More info: http://jurassic.codeplex.com/wikipage?title=Supported%20types

        // Examples of exposing some static classes to JavaScript using Jurassic's "seamless .NET interop" feature.
        engine.EnableExposedClrTypes = true;         // You must enable this in order to use interop feaure.

        // engine.SetGlobalValue("Mathf", typeof(Mathf));
        // engine.SetGlobalValue("Input", typeof(Input));
        // engine.SetGlobalValue("Transform", typeof(Transform));

        /////////////////////////////////////////////// HERE HAS PROBLEM. //////////////////////////////////////////////////
        engine.SetGlobalValue("myShips", myShipsJS);
        engine.SetGlobalValue("allyShips", allyShipsJS);
        engine.SetGlobalValue("enemyShips", enemyShipsJS);
        engine.SetGlobalValue("bullets", bulletsJS);
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        // Exposing .NET methods to JavaScript.
        // The generic System.Action delegate is used to define method signatures with no returns;
        //engine.SetGlobalFunction("SetShipSpeed", new System.Action<double>(SetShipSpeed));
        //engine.SetGlobalFunction("SetShipAngleSpeed", new System.Action<double>(SetShipAngleSpeed));
        //engine.SetGlobalFunction("Shoot", new System.Action(Shoot));
        engine.SetGlobalFunction("log", new System.Action <string>(Log));
        engine.SetGlobalFunction("polar", new Func <ObjectInstance, ObjectInstance>(Polar));
        engine.SetGlobalFunction("polarFrom", new Func <ObjectInstance, ObjectInstance, ObjectInstance>(PolarFrom));
        engine.SetGlobalFunction("cos", new Func <double, double>(Cos));
        engine.SetGlobalFunction("sin", new Func <double, double>(Sin));
        engine.SetGlobalFunction("d2r", new Func <double, double>(D2R));
        engine.SetGlobalFunction("r2d", new Func <double, double>(R2D));
        engine.SetGlobalFunction("dist", new Func <ObjectInstance, ObjectInstance, double>(Distance));
        engine.SetGlobalFunction("random", new Func <double>(Random));

        engine.SetGlobalValue("dt", engine.Number.Construct(0.02));
        engine.SetGlobalValue("groundRadius", engine.Number.Construct((double)GameValueSetter.groundSize));

        engine.SetGlobalValue("shipMaxAmmo", engine.Number.Construct((double)Ship.maxAmmo));
        engine.SetGlobalValue("shipMaxHp", engine.Number.Construct((double)Ship.maxHp));
        engine.SetGlobalValue("shipMaxSpeed", engine.Number.Construct((double)Ship.maxSpeed));
        engine.SetGlobalValue("shipMaxAngleSpeed", engine.Number.Construct((double)Ship.maxAngleSpeed));
        engine.SetGlobalValue("bulletSpeed", engine.Number.Construct((double)Bullet.speed));

        // Examples of exposing some .NET methods with return values to JavaScript.
        // The generic System.Func delegate is used to define method signatures with return types;
        //engine.SetGlobalFunction("GetPos", new System.Func<jsVectorInstance>(GetPos));
        //engine.SetGlobalFunction("GetX", new System.Func<double>(jsGetX));
        //engine.SetGlobalFunction("GetY", new System.Func<double>(jsGetY));
        //engine.SetGlobalFunction("GetZ", new System.Func<double>(jsGetZ));
        //engine.SetGlobalFunction("GetText", new System.Func<string>(jsGetText));

        // Example of creating a static .NET class to expose to JavaScript
        //engine.SetGlobalValue("Days", new jsDayIterator(engine));

        // Example of creating an instance class with a constructor in JavaScript
        //engine.SetGlobalValue("Vector", new jsVectorConstructor(engine));
        //Debug.Log("end Awake");
        //ships = new System.Json.JsonObject();
        ready = true;
    }
コード例 #3
0
 void Awake()
 {
     aiInfor = gameObject.GetComponent <TeamAIInformation> ();
 }